Solution Code: 1BCI
This assignment is related to "ITAssignment" and experts at My Assignment Services AU successfully delivered HD quality work within the given deadline.
Objectives
This assessment item relates to the course learning outcomes as in the Course Profile.
Details
For this assignment, you are required to develop a Java Console Program to demonstrate you can use Java constructs including input/output via a command line, 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 six weeks of the course, you must use the Scanner object for input and no advanced data structures like arrays will be used. Instructions for this appear in the implementation section of this specification.
What to submit for this assignment
The Java source code:
CarPark.java
A report including a flow chart (UML activity diagram) to depict your validation loop for reading the hours, how long it took to create, any problems encountered and screen shots of the output produced. (Use Alt-PrtScrn to capture just the console window and you can paste it into your Word document) You should test every possibility in the program.
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
The Rocky car park management has asked you to write a program to help employees determine the fees for cars using their car park and to also produce some statistics
You are to write a Java Console Application (CarPark.java) which will allow employees to enter the details of N cars’ licence plate and the number of hours spent at the Rocky car park. N should be equal to the highest digit in your student ID, use N=3 if your highest digit is less than three. For each car the program will prompt for and accept the licence plate number of the car and the length of stay at the car park (in whole hours), it will then display the total cost of parking (see sample output below for formatting details).
When all cars’ licence plate numbers and hours stayed have been entered you need to report the maximum and minimum stay (in hours) and the relevant licence plate numbers, the average stay and the total parking fees which have been collected.
The required Java Console Application should allow the user to:
These assignments are solved by our professional IT Assignment Experts at My Assignment Services AU and the solution are high quality of work as well as 100% plagiarism free. The assignment solution was delivered within 2-3 Days.
Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
Flow chart for Car Parking System:
Screen Shots of Testing:
Given all correct inputs
Prompting the correct inputs of license plate number and Number of hours stay for Car1:
Prompting the correct inputs of license plate number and Number of hours stay for Car2:
Prompting the correct inputs of license plate number and Number of hours stay for Car3:
Checking Maximum and minimum number of hours stay
Checking for maximum and minimum number of stay
Checking for maximum and minimum number of stay
Work around:
It took a week around to develop the coding with the help of topics covered in the first six weeks of course. All the materials has been referred and code is implemented on the course basis.
Problem encountered:
With the Decimal formatting. It has been resolved and string format is used in the code in order to display the real values with two decimal points
//Student name
//Student ID
//Date
//File name
//Purpose of the file
import java.util.Scanner;
public class CarPark {
public static void main(String[] args) {
//Variable Student_id to find the number of cars
int student_id=12022033;
int student_id1=student_id;
//to get the license plate number and number of hours stay
String license_plate1;
int no_of_hoursstay1;
String license_plate2;
int no_of_hoursstay2;
String license_plate3;
int no_of_hoursstay3;
//to calculate the parking fees for each car
double parking_fee1=0;
double parking_fee2=0;
double parking_fee3=0;
//to calculate the average number of hours
double average=0;
double count=0;
//to calculate the parking fees according to number of hours stay
final double first_hour=7.50;
final double three_hour=4.50;
final double four_hour=3.50;
final double rem_hour=2.50;
//to calculate the total fees of the car parking
double total_fees=0;
int last_digit;
int n=0;
//Printing the welcome message of the parking system
System.out.println("==========Welcome to the Rocky car park system==========");
//To Find the highest digit in the student id
while(student_id1>0){
last_digit=student_id1%10;
if(last_digit>n){
n=last_digit;
}
student_id1=student_id1/10;
}
System.out.println("The highest digit in the my student_id 12022033 is" +n);
//To get the input values for license plate number and number of hours stay
Scanner license=new Scanner(System.in);
Scanner hoursstay=new Scanner(System.in);
System.out.println();
//To get the license plate number of car1
System.out.println("Enter the license plate number of the car 1 : ");
license_plate1=license.nextLine();
//Validating whether the license plat is a not null value
while(license_plate1==null||license_plate1.trim().isEmpty()){
System.out.println("WARNING : Car's License plate number cannot be null");
System.out.println("Enter the license plate number of the car1 : ");
license_plate1=license.next();
}
//To get the number of hours stay of the car1
System.out.println("Enter the Car's Number of hours stay "+license_plate1+" to be parked(1-12) : ");
no_of_hoursstay1=hoursstay.nextInt();
//Validating whether the number of hours is between 1 and 12
while(no_of_hoursstay1<=0 || no_of_hoursstay1>12){
System.out.println("WARNING : Number of hours stay for a car1 should be between 1 and 12");
System.out.println("Enter the Car's Number of hours stay "+license_plate1+" to be parked(1-12) : ");
no_of_hoursstay1=hoursstay.nextInt();
}
//Calculaing the parking fees for Car1
if(no_of_hoursstay1>=8){
parking_fee1=first_hour+(3*three_hour)+(4*four_hour)+((no_of_hoursstay1-8)*rem_hour);
}else if(no_of_hoursstay1<8&&no_of_hoursstay1>5){
parking_fee1=first_hour+((no_of_hoursstay1/2)*three_hour)+((no_of_hoursstay1-4)*four_hour);
}else if(no_of_hoursstay1<=5&&no_of_hoursstay1>3){
parking_fee1=first_hour+(3*three_hour)+((no_of_hoursstay1-4)*four_hour);
}else if(no_of_hoursstay1<=3&&no_of_hoursstay1>0){
parking_fee1=first_hour+((no_of_hoursstay1-1)*three_hour);
}
System.out.println("The Parking fees for car1 "+license_plate1+" for "+no_of_hoursstay1+" is : $"+String.format("%.2f",parking_fee1));
System.out.println();
//To get the license plate number of he car2
System.out.println("Enter the license plate number of the car 2 : ");
license_plate2=license.nextLine();
//Validating whether the license late is a not null
while(license_plate2==null||license_plate2.trim().isEmpty()){
System.out.println("WARNING : Car's License plate number cannot be null");
System.out.println("Enter the license plate number of the car2 : ");
license_plate2=license.next();
}
//To get the number of hours stay of the car2
System.out.println("Enter the Car's Number of hours stay "+license_plate2+" to be parked(1-12) : ");
no_of_hoursstay2=hoursstay.nextInt();
//Validating whether the number of hours stay is between 1 and 12
while(no_of_hoursstay2<=0 || no_of_hoursstay2>12){
System.out.println("Number of hours stay for a car2 should be between 1 and 12");
System.out.println("Enter the Car's Number of hours stay "+license_plate2+" to be parked(1-12) : ");
no_of_hoursstay2=hoursstay.nextInt();
}
//Calculating the parking fees for car2
if(no_of_hoursstay2>=8){
parking_fee2=first_hour+(3*three_hour)+(4*four_hour)+((no_of_hoursstay2-8)*rem_hour);
}else if(no_of_hoursstay2<8&&no_of_hoursstay2>5){
parking_fee2=first_hour+((no_of_hoursstay2/2)*three_hour)+((no_of_hoursstay2-4)*four_hour);
}else if(no_of_hoursstay2<=5&&no_of_hoursstay2>3){
parking_fee2=first_hour+(3*three_hour)+((no_of_hoursstay2-4)*four_hour);
}else if(no_of_hoursstay2<=3&&no_of_hoursstay2>0){
parking_fee2=first_hour+((no_of_hoursstay2-1)*three_hour);
}
System.out.println("The Parking fees for car2 "+license_plate2+" for "+no_of_hoursstay2+" is : $"+String.format("%.2f",parking_fee2));
System.out.println();
//To get the license plate number for car3
System.out.println("Enter the license plate number of the car3 : ");
license_plate3=license.nextLine();
//Validating the license plate number of car3 is not null
while(license_plate3==null||license_plate3.trim().isEmpty()){
System.out.println("WARNING : Car's License plate number cannot be null");
System.out.println("Enter the license plate number of the car3 : ");
license_plate3=license.next();
}
//To get the number of hours stay of the car3
System.out.println("Enter the Car's Number of hours stay "+license_plate3+" to be parked(1-12) : ");
no_of_hoursstay3=hoursstay.nextInt();
//Validaing whether the number of hours stay is between 1 and 12
while(no_of_hoursstay3<=0 || no_of_hoursstay3>12){
System.out.println("WARNING : Number of hours stay for a car3 should be between 1 and 12");
System.out.println("Enter the Car's Number of hours stay "+license_plate3+" to be parked(1-12) : ");
no_of_hoursstay3=hoursstay.nextInt();
}
//Calculating the parking fees for car3s
if(no_of_hoursstay3>=8){
parking_fee3=first_hour+(3*three_hour)+(4*four_hour)+((no_of_hoursstay3-8)*rem_hour);
}else if(no_of_hoursstay3<8&&no_of_hoursstay3>5){
parking_fee3=first_hour+((no_of_hoursstay3/2)*three_hour)+((no_of_hoursstay3-4)*four_hour);
}else if(no_of_hoursstay3<=5&&no_of_hoursstay3>3){
parking_fee3=first_hour+(3*three_hour)+((no_of_hoursstay3-4)*four_hour);
}else if(no_of_hoursstay3<=3&&no_of_hoursstay3>0){
parking_fee3=first_hour+((no_of_hoursstay3-1)*three_hour);
}
System.out.println("The Parking fees for car3 "+license_plate3+"for "+no_of_hoursstay3+" is : $"+String.format("%.2f",parking_fee3));
System.out.println();
//To display the statistics informtion of the car parking system
System.out.println("==========Statistical information for the Rocky Car park==========");
//checking for the minimum number of hours stay for the car
if((no_of_hoursstay1<Integer.MAX_VALUE)&&(no_of_hoursstay1<no_of_hoursstay2) && (no_of_hoursstay1<no_of_hoursstay3)){
System.out.println("Car1 with license plate number "+license_plate1+" has the minimum stay of "+no_of_hoursstay1+" hours");
}else if((no_of_hoursstay2<Integer.MAX_VALUE)&&(no_of_hoursstay2<no_of_hoursstay3)){
System.out.println("Car2 with license plate number "+license_plate2+" has the minimum stay of "+no_of_hoursstay2+" hours");
}else if((no_of_hoursstay3<Integer.MAX_VALUE)){
System.out.println("Car3 with license plate number "+license_plate3+" has the minimum stay of "+no_of_hoursstay3+" hours");
}
//To display the maximum number of hours stay of the car
if((no_of_hoursstay1>Integer.MIN_VALUE)&&(no_of_hoursstay1>no_of_hoursstay2) && (no_of_hoursstay1>no_of_hoursstay3)){
System.out.println("Car1 with license plate number "+license_plate1+" has the maximum stay of "+no_of_hoursstay1+" hours");
}else if((no_of_hoursstay2>Integer.MIN_VALUE)&&(no_of_hoursstay2>no_of_hoursstay3)){
System.out.println("Car2 with license plate number "+license_plate2+" has the maximum stay of "+no_of_hoursstay2+" hours");
}else if((no_of_hoursstay3>Integer.MIN_VALUE)){
System.out.println("Car3 with license plate number "+license_plate3+" has the maximum stay of "+no_of_hoursstay3+" hours");
}
//Calculating the average number of hours stay of the cars in the parking system
System.out.println();
//Variable is initialized to convert int to decimal for number of our stays
double avg1=no_of_hoursstay1;
double avg2=no_of_hoursstay2;
double avg3=no_of_hoursstay3;
average=(avg1+avg2+avg3)/3;
System.out.println("The average stay of cars in hours is : "+String.format("%.2f", average));
//Calculating the total fees of all the cars parked
total_fees=parking_fee1+parking_fee2+parking_fee3;
System.out.println("The total fees for the car parking is : "+String.format("%.2f",total_fees));
//To close the scanner objects of license and hoursstay
license.close();
hoursstay.close();
System.out.println();
System.out.println();
//Printing the end message of the system
System.out.println("Thank you for using the Rocky's Car Parking System");
System.out.println("Program wirtten by"+student_id);
}
}
Find Solution for IT assignment by dropping us a mail at help@myassignmentservices.com.au along with the question’s URL. Get in Contact with our experts at My Assignment Services AU and get the solution as per your specification & University requirement.
Trending now
The Student Corner
Subscribe to get updates, offers and assignment tips right in your inbox.
Popular Solutions
Popular Solutions
Request Callback
Doing your Assignment with our resources is simple, take Expert assistance to ensure HD Grades. Here you Go....