Programming Fundamentals COIT 11222

SOLUTION AT Australian Expert Writers

COIT11222, 2020 Term One – Page 1 of 13Programming Fundamentals COIT 11222Assessment item 1—Java Console Program
Due date:
Week 6 T120 – Midnight, Friday 24 April 2020Refer below for complete assessment item 1 requirements(Assignment One)
ASSESSMENT
Weighting:
20%
1
Length:
N/A
ObjectivesThis assessment item relates to the unit learning outcomes as in the Unit Profile.DetailsFor this assignment, you are required to develop Java Console Programs to demonstrate you can useJava constructs including input/output via a command line and using GUI dialogs, Java primitive andbuilt-in data types, Java defined objects, selection and looping statements, methods, and various otherJava commands. Your program must produce the correct results.You are only allowed to use techniques which have been covered in the first five weeks of thesubject and within the assignment literature, you must use a Scanner object for console input andno advanced data structures like arrays will be used.What to submit for this assignmentThe Java source code:You will be able to complete the assignment in weekly parts in which you will produce five javasource files. (More details below)Week1.java, Week2.java, Week3.java, Week4.java and Week5.java.Once you have completed all of the programs and you are ready to submit, compress all source filesinto a single zip file for submission, do not include your report in the zip file. Only submit a zip nota rar file. It is important the file names are correct.o Ass1.zipAlso submit a report including, how long it took to create the programs (approximately), anyproblems encountered and screen shots of the output produced. (Use Alt-PrtScrn to capture just theconsole window or your dialogs and you can paste them into your Word document) You should testevery possibility in the program and annotate your test screen shots.Important: For this assignment you are required to paste all your source code as an appendix intoyour report, do not worry about the formatting loss.o ReportAss1.docxCOIT11222, 2020 Term One – Page 2 of 13You will submit your files by the due date using the “Assignment 1 Submission” link on the Moodleunit website in the Assessment Block or in the relevant week.Assignment specificationThis assignment will require you to write small five programs, do not panic! They will be smallprograms which will cover the first five weekly topics. Usually students were required to write onelargish program to demonstrate the topics for the first five weeks. Students get themselves into troublewhen the first assignment is due as they have not practiced the basics skills necessary to complete theassignment. With the assignment divided into five programs you can complete each question as wecover the weekly topics, do not let yourself fall behind.General InstructionsEach program must contain a header comment which contains: Your name and student number, thename of the file, the date and a brief description of the purpose of the program:// Programmer: Eric Gen S01234567// File: Week1.java// Date: April 24 2020// Purpose: COIT11222 assignment one question one T120// Use println method to print initials using asterisksAll programs will be aligned and indented correctly, and contains relevant comments for declarationsand statements. All variables and objects will be declared with a meaningful name and use lowercasecamel notation:String customerName;All coding will be contained within a main method except for question five when a method will becreated and used.For this assignment you will not worry about checking numeric ranges or data types.Refer to a Java reference textbook and the unit material (available on the unit WEBsite) for further information about the Java programming topics required to complete this assignment.Check the marking guide (last page) to ensure you have completed every task. You need to match alloutput exactly as the sample screenshots shown below.Distance and Melbourne students can email questions directly to me, other campus students shouldseek help from your local tutor, and you can still contact me if it is urgent, I usually respond to emailsvery promptly.Good luck — Bruce McKenzie COIT11222 unit coordinator term 1 2020b.mckenzie@cqu.edu.auCOIT11222, 2020 Term One – Page 3 of 13Question one (week one topic). Writing output to the screen.Once you have written your first “Hello World” program you will be able to complete question one.ImplementationCreate a class called Week1 (file: Week1.java) and within it a main method.Use the command System.out.println(“”); to print out the first initial of your first and lastnames as a matrix of asterisks. For example this is my first and last initials printed.The first line of asterisks is printed with this command:System.out.println(“****** * *”);You may need to use some graph paper to plot where you need to print your asterisks.If you like you could submit a picture. An attempt at Mickey Mouse! Just do your initials as it takes awhile to create a picture.COIT11222, 2020 Term One – Page 4 of 13Question two (week 2 topics) Input of data types and arithmeticexpressionsRocky Woodfired Pizzas program.Rocky Woodfired Pizzas is a shop which sells woodfired pizzas in the Rockhampton area.The cost of the base pizza which consists of tomato pizza sauce and cheese is $10.50.The customers can choose any number of extra toppings (e.g. hot salami, ham, anchovies etc.) at acost of $1.25 per topping.For simplicity we will omit what toppings will be added.These dollar values need to be stored as constants in your program using the final keyword e.g.final double BASE_CHARGE = 10.50;The management of Rocky Woodfired Pizzas are requesting a program which allows staff to input acustomer’s name and the number of toppings to be added to the base pizza (this value could be zero).The program will compute the cost of the pizza.This program will prompt for and read in a customer name using a Scanner object.The customer name will be stored in a String object.The program will then output the customer name in a prompt to read in the number of toppings (as awhole number i.e. an integer).Finally the program will display the receipt for the customer.You need to replicate the output exactly as shown below, including the correct line spacing.ImplementationCreate a class called Week2 (file:Week2.java) and within it a main method as per question one.Import the Scanner class i.e.import java.util.Scanner;COIT11222, 2020 Term One – Page 5 of 13Within your main method create two Scanner objects named inText and inNumber. One for readingtext and the other for reading the numbers, it does not really matter here to have separate Scannerobjects but there will be problems later when reading a series of text and numbers (see text pg 77 orpg 81 8th edition).Create a prompt using System.out.print(); To ask the user for the customer name.Declare a String object customerName to store the customer name and use your inText Scannerobject and the inbuilt method inText.nextLine();The customer name is now stored in the String object customerName.We can now create a prompt using the customer name to ask for the number of toppings to be addedto the pizza.Hint: you can join variables and strings using the concatenation operator +“Enter the number of extra toppings for ” + customerName + ” ==> “Declare an integer variable to store the number of toppings and use your inNumber Scanner objectand the inbuilt method inNumber.nextInt(); to read the number of toppings.Declare a double variable to represent the charge for the pizza.The arithmetic expression to calculate the total charge is very simple:charge = base charge + (number of toppings * charge per topping)Note: the base charge and the charge per topping must be stored as constants (use the final keywordsee above).Finally output a receipt for the pizza as per the sample above.The total charge must be displayed to two decimal points use printf and a format string as follows:System.out.printf(“$%.2f”, charge);Question three (week three topics) Decision statementsThe management of Rocky Woodfired Pizzas has decided to give customers a choice of differentpizza sizes: small, medium (as per week 2) and large. The new pricing scheme is as follows:Small base: $6.50Small toppings: 75 cents ($0.75)Medium base: $10.50Medium toppings: $1.25Large base: $14.50Large toppings: $1.75COIT11222, 2020 Term One – Page 6 of 13Look at the examples below to check your calculations.Create a class Week3 (file: Week3.java) and a main method and copy your code from question twointo the main method of week three main.Hint: to print a quotation mark in the prompt use ”.After you have read the relevant details of the order i.e. name, pizza size and number of toppings, youwill have to create a series of if – else if statements to calculate the final charge.Read the pizza size into a string and use pizzaSize.equalsIgnoreCase(“s “) in your ifconditions to determine the size which has been entered. Do the calculations as per week 2 but adjustthe relevant prices with extra constants for small and large pizzas.Your output needs to match exactly the output as shown below.COIT11222, 2020 Term One – Page 7 of 13(Question four next page)COIT11222, 2020 Term One – Page 8 of 13Question four (week four topics) Repetition while and for loopsCreate a class Week4 (file:Week4.java) to demonstrate the use of a repetition statement.ImplementationUsing your solution to question three and a while or for loop, repeat the entry of pizza orders Ntimes where N is the largest digit in your student ID, if your largest digit is less than three then letN = 3. Hint: use N = 3 while testing and submit using the correct N value.N will be declared as an integer constant using the final keyword.You are to print a title before the input of the pizza orders (see sample output). Note the different linespacing. You will also number the customer in the customer name prompt.Ensure you are using a separate Scanner objects for reading numbers and text .When all of the pizza orders have been entered and their individual charges calculated, the average ofthe number of the toppings for each pizza and the total of the charges collected will be reported.Please note you do not need to store the data in an advanced structure such as an array. Youwill need to have an integer variable to add up the number of toppings to calculate the average, and adouble variable to add up the charges.Your average toppings per pizza calculation must produce a floating-point result. To get a floatingpoint result you will need to promote one of the operands to a double.i.e. average = totalToppings * 1.0 / NSample output is on the following page.COIT11222, 2020 Term One – Page 9 of 13Sample output for question four.COIT11222, 2020 Term One – Page 10 of 13Question five (week five topics) Methods and GUI I/OCreate a class Week5 (file:Week5.java) by using your solution to question four. This question isidentical to question four as the program will read in N pizza orders and calculate the charges for theorders, however we are going to create a method to calculate the charges and we will be using GUIdialog boxes for our I/O.ImplementationMethodsYou will create a value returning method which will accept the pizza size and the number of toppingsas a parameter.Use the following method header:private static double calculateCharge(String size, int toppings)Copy and paste your “if else if” code from question four for calculating the charge into the body ofour new method calculateCharge. You should also copy the constants for the numeric literals into themethod too. Use the return statement to return the charge.You can now use your method in the main method loop.charge = calculateCharge(pizzaSize, toppings);GUI I/OWe will revisit the week two lecture topic using JOptionPane for accepting GUI input andoutputting information.First we will output a welcome message using JOptionPane.showMessageDialog (Replaceyour console print output).Next we will replace the Scanner objects by using JOptionPane.showInputDialog.COIT11222, 2020 Term One – Page 11 of 13The showInputDialog method will return the string entered into the dialog text fieldcustomerName = JOptionPane.showInputDialog(null, “Prompt”);Read in the size of the pizza.Next you will need to prompt for the number of toppings.We receive input from the dialog as a string, in order to convert strings to an integer we need theInteger wrapper class and the parseInt method (text pg 347 or pg 370 8th Edition).int anInteger =Integer.parseInt(JOptionPane.showInputDialog(null, “Prompt”));After reading in and converting the number of topping to an integer you can use this value to calculatethe charge for the order using your method:Output the receipt using JOptionPane.showMessageDialog(null, “text”)COIT11222, 2020 Term One – Page 12 of 13To format your output in the text argument in showMessageDialog you can use:String.format(“Format string”,args)See the example below for using place holders to format strings, integers and doubles.String.format(“%sn%sn%dn$%.2f”,customerName, pizzaSize, toppings, charge)%s is for a string.%d is for an integer.%.2f is for a floating point number (including double) formatted to two decimal places.The n will produce a newline and you will need to add extra text to the format string to match theoutput above.When the N orders have been entered you will output the average number of toppings per pizza andthe total charges collected both to two decimal places, you can use a similar format string as above.The marking scheme is on the next page.COIT11222, 2020 Term One – Page 13 of 13Marking scheme
Total number of marks – 20
Code in general
Code is indented and aligned correctly, layout including vertical whitespace is good
1
Code has header comment which includes student name, student ID,date, file name and purpose of the class
0.5
Code is fully commented including all variables
1
Variables have meaningful names and use camel notation
0.5
Variables are the correct type
0.5
Question one
Output as per specification
1
Question two
Strings are read correctly using Scanner object
0.75
The integer is read correctly using a Scanner object
0.75
The order charge is computed and displayed correctly to two decimalplaces
0.5
Output is formatted correctly (matches sample output)
0.5
Question three
If else statements are correct and constants are used
1.5
Correct charge is calculated and displayed correctly to two decimal places
0.5
Output is formatted correctly (matches sample output)
0.5
Question four
Constant N used equal to highest digit in student ID
0.5
N customer names, size and number of toppings are read in a loop
1
Program title “Rocky Woodfired Pizzas Entry System” printed
0.25
Charges printed for all orders
0.25
Average toppings per pizza and total charges are calculated and printedcorrectly to two decimal places
1
Output is formatted correctly (matches sample output)
0.5
Question five
Method implementation (uses parameters)
1
Dollar (double) value returned from method correctly
0.5
Method call correct (uses an argument)
0.5
GUI welcome message
0.25
Strings are read correctly from GUI Input dialogs
0.25
Number of toppings are read correctly from GUI Input dialog andconverted to an integer
0.5
N pizza orders are read in a loop
0.25
Average and total are calculated and printed correctly to two decimalplaces
0.5
Dialogs appear as per specification (matches sample output)
0.25
General
Correct files submitted including types and names (zip and Word)
0.5
Only techniques covered during weeks 1-5 and specification are used
0.5
Report
Report presentation and comments including how long the programs tookto create and any problems encountered
0.5
Screen shots of testing and annotations
0.5
Source code is supplied as an appendix
1

Order from Australian Expert Writers
Best Australian Academic Writers

QUALITY: 100% ORIGINAL PAPERNO PLAGIARISM – CUSTOM PAPER

Assignment status: Already Solved By Our Experts

YOU MAY ALSO READ ...  Marketing Research in Action

(USA, AUS, UK & CA Ph. D. Writers)

CLICK HERE TO GET A PROFESSIONAL WRITER TO WORK ON THIS PAPER AND OTHER SIMILAR PAPERS, GET A NON PLAGIARIZED PAPER FROM OUR EXPERTS

Order from Australian Expert Writers
Best Australian Academic Writers

QUALITY: 100% ORIGINAL PAPER – NO PLAGIARISM – CUSTOM PAPER