java programing

profileskulcandy1190
JavaApplication7.java

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package javaapplication7; import java.util.Scanner; /** * * @author ehsan */ public class JavaApplication7 { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here System.out.println("Welcome to the Car rental Calculator"); Scanner input = new Scanner(System.in); System.out.println("Enter First Name: "); String firstName = input.nextLine();//takes first name as input System.out.println("Enter Last Name: "); String lastName = input.nextLine();//takes last name System.out.println("Enter Car Type: "); String carType = input.nextLine();//takes car type System.out.println("Enter Week Days: "); double weekDays = input.nextInt();//takes number of week days System.out.println("Enter Weekend Days: "); double weekendDays = input.nextInt();//takes number of weekend days System.out.println("Enter Rental Amount Paid: "); double rentalAmount;//takes input the rental amount paid rentalAmount = input.nextDouble(); System.out.println("Car Rental Calculator Result"); System.out.println("Customer: " + firstName + " " + lastName); System.out.println("Car Type: " + carType); System.out.println("Days: " + weekDays + " [Week Days] " + weekendDays + " [Weekend Days]"); double CompactPriceWeekDays = 29.99; double CompactPriceWeekend = 39.99; double MidSizePriceWeekDays = 39.99; double MidSizePriceWeekend = 49.99; double SedanPriceWeekDays = 49.99; double SedanPriceWeekend = 59.99; double NationalAvrage = input.nextDouble(); switch (carType) { case "Compact": //if cartype is compact NationalAvrage = ((CompactPriceWeekDays) * weekDays)+ ((CompactPriceWeekend) * weekendDays); break; case "MidSize": //if cartype is MidSize NationalAvrage = ((MidSizePriceWeekDays) * weekDays) + ((MidSizePriceWeekend) * weekendDays); break; case "Sedan": //if cartype is Sedan NationalAvrage = ((SedanPriceWeekDays) * weekDays) + ((SedanPriceWeekend )* weekendDays); break; default: break; } System.out.println("Paid: " + (rentalAmount)); System.out.println("National Average: " + (NationalAvrage)); if (rentalAmount >= ( NationalAvrage + 5.0)) {//if total amount if 5 more than national average System.out.println("Rental Comparison Result: Expensive"); } else if (rentalAmount <= (NationalAvrage - 5)) {//if total amount if 5 less than national average System.out.println("Rental Comparison Result: Bargain"); } else if (rentalAmount > (NationalAvrage - 5) && rentalAmount < (NationalAvrage + 5)) {//if total amount if 5 plus minus national average System.out.println("Rental Comparison Result: Average"); } System.out.print("Do you want to enter another rental? (Yes, No): "); String option; input.nextLine(); option=input.nextLine(); if (option.equals("No")) { //if user decides to not continue break our of loop //<editor-fold defaultstate="collapsed" desc="comment"> } } }