Develop a java console programs

Assignment Help Other Subject
Reference no: EM132361602

Objectives

This assessment item relates to the course learning outcomes as in the Unit Profile.

Details

For this assignment, you are required to develop a Java Console Programs to demonstrate you can use Java constructs including input/output via a command line and using GUI dialogs, Java primitive and built- in data types, Java defined objects, selection and looping statements, methods, and various other Java 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 the subject and within the assignment literature, you must use a Scanner object for console input and no advanced data structures like arrays will be used.

What to submit for this assignment

The Java source code:

You will be able to complete the assignment in weekly parts in which you will produce five java source 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 files into a single zip file for submission, do not include your report in the zip file. Only submit a zip not a rar file

o Ass1.zip
Also submit a report including, how long it took to create (approximately), any problems encountered and screen shots of the output produced. (Use Alt-PrtScrn to capture just the console window or your dialogs and you can paste it into your Word document) You should test every possibility in the program and annotate your test shots.
o ReportAss1.docx
You will submit your files by the due date using the "Assignment 1" link on the Moodle course website in the Assessment Block or in the relevant week.

Assignment specification

This assignment will require you to write five small Java programs, do not panic! They will be small programs which will cover the first five weekly topics. Usually students were required to write one largish program to demonstrate the topics for the first five weeks. Students may get themselves into trouble when the first assignment is due as they have not practiced the basics skills necessary to complete the assignment. With the assignment divided into five programs you can complete each exercise as we cover the weekly topics, do not let yourself fall behind. More importantly, this is a progressive way to complete the assignment. Each small program is built on its previous one (you can re-use the previous small program code), except the first one.
General Instructions

Each program must contain a header comment which contains: Your name and student number, the name of the file, the date and a brief description of the purpose of the program:
// Programmer: Eric Gen S01234567
// File: Week1.java
// Date: August 30 2019
// Purpose: COIT11222 assignment one question one T2-19
// Use Scanner object to input data and display them

All programs will be aligned and indented correctly, and contains relevant comments for declarations and statements. All variables and objects will be declared with a meaningful name and use lowercase camel notation:

String customerName;

All code will be contained within a main method except for question five when a user defined method will be created and used, in addition to the main method.
For this assignment you will not worry about checking numeric ranges or data types.

Refer to a Java reference textbook and the course and lecture material (available on the course WEB site) 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 all outputs similarly as the sample screenshots shown below.
Distance and Rockhampton students can email questions directly to me, other metro campus students should seek help from your local tutor, you can still contact me if it is urgent, I usually respond to emails very promptly.

Question one (week one topic) - Writing output to the screen

Once you have written your first "Hello World" program you will be able to complete questionone.

Implementation

Create a class called Week1 (file: Week1.java) and within it a main method.

Use the command System.out.println("") to print out the following shape as a matrix of asterisks.

The first line of asterisks is printed with this command:

System.out.println("*********");

You may need to use some graph paper to plot it if you print a complicated pattern with asterisks.

Alternatively, you can print out the first initial of your first and last names as a matrix of asterisks for Week1.java. For example this is my first and last initials printed.

Question two (week two topics) Input of data types and arithmetic expressions
XYZ Courier Service Application Program
This program will allow staff at the XYZ Courier Service to compute the delivery fee of a customer who wants to deliver a parcel. For simplicity, we assume that there is an initial flat delivery rate of
$9.50 per kilogram.
This program will prompt for and read in a customer's name using a Scannerobject and prompt to read the customer's contact phone. The customer name and contact phone will be stored in String objects. Then the program will then output the name in a prompt to input the weight of a parcel that a customer asks to deliver. The weight (kg) of a parcel should be declared as a whole number i.e. an integer.

After all inputs and hitting the Enter button on the keyboard, the program is executed and will display a receipt of delivery. You need to replicate the output similar to the image as below.

Implementation

Create 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;
Within your main create two Scanner objects named inText and inNumber. One for reading text and the other for reading the numbers, it does not really matter here to have separate Scanner objectsbut there will be problems later when reading a series of text and numbers (see text pg 77).
Create a prompt using System.out.print(); To ask the user for the name of the customer. Declare a String object customerName to store the customer's name and use your inText
Scanner object and the inbuilt method inText.nextLine();
The customer name is now stored in the String object customerName.

Read the contact phone as the same way you read in the customer name and store it in a String object.

We will need to create a prompt using the customer's name to ask for the weight of a parcel. Hint: you can join variables and strings using the concatenation operator +
"Enter the weight of " + customerName + "'s parcel: "

Declare an integer variable to store the weight of a parcel and use your inNumber Scanner object and the inbuilt method inNumber.nextInt(); to read the number. Declare a double variable to represent the delivery fee.

The arithmetic expression to calculate the delivery fee is very simple:

fee = weight * RATE

Note: the rate per kilogram must be stored as a constant (use the final keyword). Finally output a receipt of delivery with details as per the sample above.

The delivery fee must be displayed to two decimal points use printf and a format string as follows:

System.out.printf("$%.2f", fee);

Question three (week three topics) Decision statements

The management of the XYZ Courier Service would like to promote their business and provide a better service for customers with discounted rates when the weight of a parcel exceeds a particular amount, so it was decided there would be different rates depending on the weight of their parcels. The rates now are set as follows.
2019 XYZ Courier Service Delivery Prices
1-3 kg: $9.50 per kg
From 4 to 8 kg: $7.50 per kg Over 8 kg: $6.00 per kg
Create a class Week3 (file: Week3.java) and a main method and copy your code from question two into the main method of week three main.
After you have read the relevant details of the customer name, contact phone and the weight of a parcel, you will have to create a series of if - else statements to calculate the delivery fee. When you have calculated the delivery fee output a summary as you have done in week two code. Try and devise three arithmetic expressions for the three lengths in terms of the parcel weight so your if-else statement has only three branches. Hints: to calculate the delivery fee for a 4kg parcel, the first 3kg fee plus the 4th kilogram charge (which is in a different rate) should be considered and the formula should be:

fee=3×9.5+(4-3)×7.5

Similarly, the delivery fee for a 10kg parcel should be computed in the following way,

fee=3×9.5+5×7.5+(10-8)×6.0
Your program output needs to match the similar output as shown below for the samples with the parcel weights of 4kg, 5kg and 9kg respectively.

Note: you must use constants for all the numeric literals in the else if statements.

Question four (week four topics) Repetition while and for loops

Create a class Week4 (file:Week4.java) to demonstrate the use of a repetitionstatement.

Implementation

Using your solution to question three and a while or for loop, repeat the entry of customer name, contact phone and the weight of their parcel N times, where N is the largest digit in your student ID, if your largest digit is less than three then let N = 3. Hint: use N = 3 while testing and submit using the correct N value. In addition, you need to declare 3 counter variables to record the number of parcels with the weight in the specific interval. N will be declared as an integer constant using the final keyword.

You are to print a title before the input of the customer name, contact phone and the weight of parcel (see sample output).
Ensure you are using a separate Scanner objects for reading numbers and text.

When all of the customer name, contact phone and the weight of parcel have been entered, the statistical data including the average weight of all parcels, the all total delivery fee collected, and the numbers of parcels in the specific weight interval should be reported. Please note you do not need to store the data in an advanced structure such as an array. You will need to have an integer variableto add up the weights to calculate the average, and a double variable to add up the delivery fee.

Question five (week five topics) Methods and GUI I/O

Create a class Week5 (file:Week5.java) by using your solution to question four. This question is identical to question four as the program will read in N customer name, contact phone and the weight of their parcels and calculate the delivery fee for each customer, however we are going to create a methodand we will be using GUI dialog boxes for our I/O.
Implementation

Methods

You will create a value returning method which will accept the weight of parcel as a parameter.

Use the following method header:

private static double calculateDeliveryFee(int weight)
Copy and paste your "if else" code from week4 for calculating the delivery fee into the body of our new method calculateDeliveryFee. Use the return statement to return the delivery fee.
You can now use your method in the main method loop.

fee = calculateDeliveryFee(weight);

GUI I/O

We will revisit the week two lecture topic using JOptionPane for accepting GUI input and outputting information.

First we will output a welcome message using JOptionPane.showMessageDialog (Replace your console print output).

Next we will replace the Scanner objects by using JOptionPane.showInputDialog

The showInputDialog method will return the string entered into the dialog text field customerName = JOptionPane.showInputDialog(null, "Prompt"); Do the same to read in the contact phone.

Next you will need to prompt for the parcel weight, including the customer name.

We receive input from the dialog as a string, in order to convert strings to an integer we need the Integer wrapper class and the parseInt method (text pg 347).

int anInteger =
Integer.parseInt(JOptionPane.showInputDialog(null, "Prompt"));

After reading in and converting the parcel weight to an integer you can use this value to calculatethe delivery fee using your method: fee = calculateDeliveryFee(weight);
Output the summary using: JOptionPane.showMessageDialog(null, "text")

To 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("%s\n%s\n%d\n$%.2f", customerName, contactPhone, weight,fee)
%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 the output above.

When the N customers have been entered, you will report the maximum and minimum values of delivery fee, as well as the corresponding customer names. You need to declare a double variable for maximum delivery fee and another String type variable for the corresponding customer name. Then inside the for loop, use an if statement to compare the assumed maximum delivery fee and current delivery fee. You can use the same way to deal with minimum delivery fee and the corresponding customer's name. The following image shows a sample result with the maximum and minimum delivery fees.

Attachment:- Java Console Program.rar

Verified Expert

The assignment is based on java programming language. In this program different functionalities of java programing are applied including GUI implementation for I/O. The problem has five modules. In the first module printing pattern to console output is done. In the second module, input from the user is taken using Scanner object. In the third module, decision statement is implemented. In the fourth module, the loop statement is implemented. In the last module, the GUI dialog box is implemented for showing message and taking input from user.

Reference no: EM132361602

Questions Cloud

Prove that graph of f is closed subset of the product : Question - If f is a continuous mapping of a topological space X into a Hausdorff space Y, prove that the graph of f is a closed subset of the product X x Y
Focus on how models can use real data to create forecasts : If you were an analyst working for the St. Petersburg Informational and Analytical Center, explain how you would use data available to you to make
Prepare an agenda for the meeting : CHCCOM002 - Use communication to build relationships-Victoria University-Australia-Prepare and distribute an email inviting colleagues to attend the meeting.
Previous windows edition in terms of startup problems : Why is windows 8 considered to be more a stable system than previous windows edition in terms of startup problems?
Develop a java console programs : COIT11222 - Programming Fundamentals - Java Console Program - Central Queensland University - develop a Java Console Programs to demonstrate you can use Java
Previous windows editions in term of startup problems : Why is windows 8 considered to be a more stable system than previous windows editions in term of startup problems?
Find the mean and the median : Find the mean, the median, and the mode(s), if any, for the given data
Associated with each mintzberg management roles : Provide an example of an action undertaken by your manager associated with each Mintzberg's management roles.
Explain how each type of malware works : Virus, worm, trojan, ransomware, spyware, a backdoor intrusion. In , few paragraphs about each of the malware types listed.

Reviews

len2361602

8/27/2019 12:19:18 AM

7 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 8 Report Report presentation and comments including how long the programs took to create and any problems encountered 0.5 Screen shots of testing and annotations 0.5

len2361602

8/27/2019 12:18:56 AM

6 Question five Method implementation (uses a parameter) 0.5 Dollar (double) value returned from method correctly 0.25 Method call correct (uses an argument) 0.5 GUI welcome message 0.25 Strings are read correctly from GUI Input dialogs 0.25 The parcel weight read correctly from GUI Input dialog and converted to an integer 0.5 N customer names, contact phones and weights are read in a loop 0.25 Maximum and minimum values of delivery fee are calculated and printed correctly to two decimal places. 1 Dialogs appear as per specification (matches sample output) 0.5

len2361602

8/27/2019 12:18:45 AM

4 Question three If else statements are correct and constants are used 1.25 Correct delivery fee is calculated and displayed correctly to two decimal 1.25 Output is formatted correctly (matches sample output) 0.5 5 Question four Constant N used equal to highest digit in student ID 0.5 N customer names, contact phones and weights are read in a loop 1 Program title "XYZ Courier Service Application Program" printed 0.25 Delivery fees printed for all customers 0.25 Average weight of parcels and all total delivery fee collected are calculated and printed correctly to two decimal places 1 Simple statistics results including the numbers of parcel in the specific weight interval are correctly recorded and displayed 1 Output is formatted correctly (matches sample output) 0.5

len2361602

8/27/2019 12:18:34 AM

2 Question one Output as per specification 1 3 Question two Strings are read correctly using Scanner object 0.5 The integer is read correctly using a Scanner object 0.5 The delivery fee is computed and displayed correctly to two decimal places 0.5 Output is formatted correctly (matches sample output) 0.5

len2361602

8/27/2019 12:18:25 AM

Marking Scheme Total number of marks – 20 1 Code in general Code is indented and aligned correctly, layout including vertical white space 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 0.75 Variables have meaningful names and use camel notation 0.75 Variables are the correct type 0.5

Write a Review

Other Subject Questions & Answers

  How concept of culture been defined by various anthropologis

How has the concept of culture been defined by various anthropologists? What strengths and weaknesses does each definition pose? How should anthropologists in the 21st century define and study culture?

  Criminal justice system

How might current technology be used to communicate more effectively within the various areas of the criminal justice system?

  Explain the importance of situating a society cultural

Explain how key social, cultural, and artistic contributions contribute to historical changes. Explain the importance of situating a society's cultural and artistic expressions within a historical context.

  Can corporate leaders push through immigration reform

Can corporate leaders push through immigration reform in 2014? How immigration reform - or lack thereof - is hurting our economic competiveness.

  Same sex couples and law

Should same-sex couples receive constitutional protection? In what way and to what extent is the criminal law an appropriate mechanism to deal with personal choices people make?

  What was the purpose of the police roadblock

Based on information provided can police use roadblocks for any reason, any time? In Illinois v. Lidster, what was the purpose of the police roadblock

  Essay that critically reviews the current ethical debate

Task: Present an essay that critically reviews the current ethical debate concerning evidence-based practice in counselling

  Find an article through proquest that discusses pay equity

find an article through proquest that discusses pay equity as it relates to ksas. address the importance of managing

  Which type of evil springs from the human will

1. Which type of evil springs from the human will? Provide one example.

  What role does child abuse and exposure to intimate partner

What role does child abuse and exposure to intimate partner violence play in the probability that men will grow up to become batterers?

  Develop a financial analysis of your organization

As part of this class, you are required to develop a financial analysis of your organization. The intent of this assignment is to evaluate the financial and operational health of the organization and disseminate the information to the class

  Different tiers or levels of tourism organizations

Give an example of each of the different tiers or levels of tourism organizations: international, national, state, and local?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd