Hello Im working on a school project and seem to be stuck. Any help is appreciated!
Basically my program has to compute charges for a company based on the hour of the day and the day of the week. Im stuck on the part where it is supposed to compute the fee based on the time of day
PLEASE HELP ...here is what I have so far....
import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Scanner; public class Project2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Date d = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy"); System.out.print("Plumber: "); String name = sc.next(); System.out.print("Service date (mm/dd/yyyy): "); String service_date = sc.next(); sc.useDelimiter("/"); sdf.setLenient(false); // covert input to calendar object sc = new Scanner(service_date); sc.useDelimiter("/"); //Parse input for individual values (mm/dd/yyyy) //January=0, so subtract 1 from month int month = sc.nextInt()-1; int day = sc.nextInt(); int year = sc.nextInt(); Calendar cal = Calendar.getInstance(); cal.set(year, month, day); //Get day of week, Sun=1,.. Sat=7 int n = cal.get(Calendar.DAY_OF_WEEK); Scanner sd = new Scanner(System.in); System.out.print("Starting time of service call (Military time): "); int start = 0; start = sd.nextInt(); System.out.print("Ending time of service call (Military time): "); int end = 0; end = sd.nextInt(); //Start time double startTime = (start / 100) + (start % 100.0 / 60); //End time double endTime = (end / 100) + (end % 100.0 / 60); double service_time = endTime - startTime; int base = 52; int over = 78; int saturday = 76; int overSaturday = 114; int sunday = 124; int overSunday = 186; double fee =0; // Weekday charges if basic or overtime if (n>=2 && n<=6) fee = (service_time * base); // Saturday if (n==7) fee = (service_time * saturday); // Sunday if (n==1) fee = (service_time * sunday); //output System.out.println(""); System.out.println("Leaky Plumbing Repair Company"); System.out.println("Invoice for Services"); System.out.println(""); System.out.println("Date Printed: " + sdf.format (d)); System.out.println("Plumber: " +name); System.out.println(""); System.out.println("Service date: "+service_date); System.out.println("Service hours: " +service_time); System.out.println(""); System.out.println("Charges:" +fee); } }