我爲我的CSE 20課程做了第一個項目,我必須編寫一個簡單的租賃汽車系統。我一開始就陷入困境。我需要問車子,天數,然後你是否是俱樂部會員。如果你的代碼不需要繼續並輸出它的總數。但是如果你是一個俱樂部會員,它必須提出另一個關於高管包的問題,那麼這就增加了總輸出的另一條線。我不知道如何編寫代碼才能完全運行。任何幫助,將不勝感激。要求變量只有如果爲真
import java.util.Scanner;
public abstract class Bobcar1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner blah = new Scanner(System.in);
System.out.println("Available cars: 1 for Econobox, 2 for Compact, 3 for Standard");
System.out.print("Please choose the rental car: ");
int car;
car = blah.nextInt();
System.out.print("Please enter the number of rental days: ");
int day;
day = blah.nextInt();
System.out.print("Club member?: 1 for yes, 0 for no: ");
int re;
re = blah.nextInt();
if (re == 1)
System.out.print("Platinum Executive Package?: 1 for yes, 0 for no: ");
int pack;
pack = blah.nextInt();
if (re == 0) then what do i code here to get the program to run through completely?
if (car == 1) {
int car1;
car1 = (25 * day);
System.out.println("Base: " + day + " day(s) for a Econobox @ $25 per day: " + "+$" + car1);
if (pack == 0 && re == 0) {
System.out.println();
System.out.println("Total Estimate for Rental: " + " $" + car1);
}
if (re == 1 && pack == 0) {
int re1;
re1 = (day/5)*25;
System.out.println("Club Member Discount: " + "-$" + re1);
int total1r;
total1r = car1 - re1;
System.out.println();
System.out.println("Total Estimate for Rental: " + " $" + total1r);
}
if (pack == 1 && re == 1) {
int pack1;
pack1 = (int) (car1*.20);
System.out.println("Platinum Executive Package: " + "+$" + pack1);
int re1;
re1 = (day/5)*25;
System.out.println("Club Member Discount: " + "-$" + re1);
int total1;
total1 = car1 + pack1 - re1;
System.out.println("Total Estimate for Rental: " + " $" + total1);
}
}
if (car == 2) {
int car1;
car1 = (55 * day);
System.out.println("Base: " + day + " day(s) for a Compact @ $55 per day: " + "+$" + car1);
if (pack == 0 && re == 0) {
System.out.println();
System.out.println("Total Estimate for Rental: " + " $" + car1);
}
if (re == 1 && pack == 0) {
int re1;
re1 = (day/5)*55;
System.out.println("Club Member Discountt: " + "-$" + re1);
int total1r;
total1r = car1 - re1;
System.out.println();
System.out.println("Total Estimate for Rental: " + " $" + total1r);
}
if (pack == 1 && re == 1) {
int pack1;
pack1 = (int) (car1* .20);
System.out.println("Platinum Executive Package: " + "+$" + pack1);
int re1;
re1 = (day/5)*55;
System.out.println("Club Member Discount: " + "-$" + re1);
int total1;
total1 = car1 + pack1 - re1;
System.out.println("Total Estimate for Rental: " + " $" + total1);
}
}
if (car == 3) {
int car1;
car1 = (100 * day);
System.out.println("Base: " + day + " day(s) for a Standard @ $100 per day: " + "+$" + car1);
if (pack == 0 && re == 0) {
System.out.println();
System.out.println("Total Estimate for Rental: " + " $" + car1);
}
if (re == 1 && pack == 0) {
int re1;
re1 = (day/5)*100;
System.out.println("Return Customer Discount: " + "-$" + re1);
int total1r;
total1r = car1 - re1;
System.out.println();
System.out.println("Total Estimate for Rental: " + " $" + total1r);
}
if (pack == 1 && re == 1) {
int pack1;
pack1 = (int) (car1*.20);
System.out.println("Platinum Executive Package: " + "+$" + pack1);
int re1;
re1 = (day/5)*100;
System.out.println("Club Member Discount: " + "-$" + re1);
int total1;
total1 = car1 + pack1 - re1;
System.out.println("Total Estimate for Rental: " + " $" + total1);
}
}}}}
這將是更容易幫助你,如果你要問一個具體問題。任何幫助將不勝感激是一個聲明。你想得到什麼幫助? – axiopisty
我如何編碼它只有當有一個俱樂部會員,要求沒有它的鉑金包,只是在那裏停止?當我運行它時,它會運行到那時停止。 –
如何要求*鉑金包*在功能上與請求*俱樂部會員*有所不同?後者顯然是可以的。 –