Hey guys,
Im new to this forum and I really never thought my schooling would be this bad to find help from an online community..but heres the deal:
Im a masters student in MIS and I needed this java programming course for my degree. I figured it would be pretty easy except my professor doesnt teach us anything. I have been trying to learn on my own through the book and youtube videos and colleagues, which it was going pretty well for a little while. However, my professor gives us really hard programs to do and no one in the class knows how to solve them, not even the guy who writes 2 other languages. So I desperately need help cuz I have no idea what I'm doing. Here's the problem he gave us:::
A parking garage charges a $2 minimum fee to park for up to 3 hours. The garage charges and additional .50 cents per hour or part thereof, in excess of three hours. The max charge for any 24 hour period is $10. Assume that no car parks for longer than 24 hours at a time. Writ a java app which will calculate and display the parking charges for each customer who parked in the garage yesterday. You should wnter the hours parked for each customer. The program should display the charge for the current customer and should calculate and display the running total of yesterday's receipts.
The program should have at least 3 methods:
1. Enter and return the hours parked by a customer
2. Calculate and return the charge given it was sent to the hours parked
3. Send the charge for each customer and the running total thus far and prints them
The output should look somethng like this:::
Enter hours this customer parked: 2.5
The charge for this customer is $2.00
The total for the day is $2.00
Enter hours this customer parked: 5
The charge for this customer is $3.00
The total for the day is $5.00
and so on....
Its supposed to be a program for multiple methods but I did multiple classes bc its the only way I know how to do it. Here is what I have so far...
My main method:::
import java.util.Scanner; class Prog_4{ public static void main(String[] args){ Scanner input = new Scanner(System.in); hours hoursObject = new hours(); System.out.println("Enter the number of hours parked: "); double temp = input.nextDouble(); hoursObject.setHours(temp); hoursObject.summary(); charge chargeObject = new charge(); double cost = input.nextDouble(); chargeObject.setCharge(cost); chargeObject.rateSummary();
My hours class:::
public class hours{ public double numberOfHours; public void setHours(double hours){ numberOfHours = hours; } public double getHours(){ return numberOfHours; } public void summary(){ System.out.printf("The number of hours parked was %s", getHours()); } }
MY charge class:::
public class charge{ public double rate; public void setCharge(double charge, double hours){ if(hours<=3.0){ (charge= "$2.00"); } else if(hours<= 4.0){ (charge= "$2.50") } else if(hours<=5.0){ } } } } public double getCharge(){ return rate; } public void rateSummary(){ System.out.printf("The charge for this customer is %s", getCharge());
I'd greatly appreciate any help at all. Even if you could just dumb it down for me and get me in the right direction.
Thanks so much!