Hey so I have a code here designed to give the best rate on a car rental with the weekly and daily prices as constants. The code will take the color, type of rental, and amount of days but does not output anything. Am I missing something?
import java.util.*;
import java.util.Scanner;
public class lab3
{
public static final char E = 'E';
public static final int ZERO = 0;
public static final double ECONOMY_DAILY = 25.5;
public static final double FULL_DAILY = 39.4;
public static final double ECONOMY_WEEKLY = 120.5;
public static final double FULL_WEEKLY = 216.25;
public static void main (String[] args)
{
Scanner Keyboard = new Scanner(System.in);
Locale locale = Locale.getDefault();
System.out.println("Enter the color of the vehicle:");
String color = Keyboard.next();
System.out.println ("Economy or Full:");
String Type = Keyboard.next();
char FirstTypeLetter = Type.toUpperCase()
.charAt(0);
System.out.println("For how many days?");
int Days = Keyboard.nextInt();
int Weeks = Days/7;
int DaysLeftover = Days%7;
switch (FirstTypeLetter)
{
case 'E':
double Rate1 = Weeks * ECONOMY_WEEKLY;
double Rate2 = (Weeks * ECONOMY_WEEKLY) + (Days * ECONOMY_DAILY);
double Rate3 = (Days * ECONOMY_DAILY);
if ((Rate1 > Rate2)&(Rate1>Rate3))
{
System.out.println("This is the best rate for a" + " " + color + " " + Type + " vehicle for" + " " + Days + "days:" + Rate1);
if ((Rate2>Rate1)&(Rate2>Rate3))
{
System.out.println("This is the best rate for a" + " " + color + " " + Type + " vehicle for" + " " + Days + "days:" + Rate2);
}
else if ((Rate3>Rate2) & (Rate3>Rate1))
{
System.out.println("This is the best rate for a" + " " + color + " " + Type + " vehicle for" + " " + Days + "days:" + Rate3);
switch (FirstTypeLetter)
{
case 'F':
double FullRate1 = Weeks * FULL_WEEKLY;
double FullRate2 = (Weeks * FULL_WEEKLY) + (Days * FULL_DAILY);
double FullRate3 = (Days * ECONOMY_DAILY);
if ((Rate1 > Rate2) & (Rate1 > Rate3))
{
System.out.println("This is the best rate for a" + " " + color + " " + Type + " vehicle for" + " " + Days + "days:" + FullRate1);
}
if ((FullRate2 > FullRate1) & (FullRate2 > FullRate3))
{
System.out.println("This is the best rate for a" + " " + color + " " + Type + " vehicle for" + " " + Days + "days:" + FullRate2);
}
else if ((FullRate3 > FullRate1) & (FullRate3 > FullRate2))
{
System.out.println("This is the best rate for a" + " " + color + " " + Type + " vehicle for" + " " + Days + "days:" + FullRate3);
}
break;
default:
System.out.println("Try Again!");
}
}
Aucun commentaire:
Enregistrer un commentaire