i have write program displays number of motorbikes, customer rent motorbike , bike no longer available. have record time of renting , when person returning have record returning time , calculate cost. i'm noob programmer. if explain in simple matter how finish this. have written this. thank time.
scanner s = new scanner(system.in); byte numbikes = 15; boolean[] available = new boolean[numbikes]; string [] timerented = new string [numbikes]; arrays.fill(available , true); system.out.println("the following bikes avaialable:\n"); for(byte b = 0; b <= numbikes - 1; b++) if(available [b]== true){ system.out.println(" bike no" + (byte)(b+1)); } system.out.print("enter bike number want choose"); byte bikeno = s.nextbyte(); if (available[bikeno - 1]== true) available[bikeno - 1] = false; system.out.println("the following bikes avaialable:\n"); for(byte b = 0; b <= numbikes - 1; b++) if(available [b]== true){ system.out.println(" bike no" + (byte)(b+1)); }
i made sample promp user calculated cost because don't know how want calculate cost don't know rent hope can change in letter b choice
import java.util.*; public class { public static void main(string[] args) { scanner scan = new scanner(system.in); int numbikes =15; int availablebike=15; int bikefound=0; boolean[] available = new boolean[numbikes]; string[] timerented = new string [numbikes]; string[] returningtime = new string[numbikes]; int[] calculatecost = new int[numbikes]; arrays.fill(available,true); string choice=""; { system.out.println("what want zzz quit?"); system.out.println("a.rent bike b. return bike"); choice = scan.nextline(); if(choice.charat(0)=='a') { system.out.println("the following bikes available:\n"); for(int b = 0; b <= numbikes - 1; b++) if(available [b]== true) system.out.println(" bike no:" + (b+1)); system.out.println("enter bike number want choose"); int bikeno = scan.nextint(); scan.nextline(); if(availablebike>0) { if(available[bikeno-1]==true) { available[bikeno-1]=false; system.out.println("enter time of renting"); timerented[bikeno-1]=scan.nextline(); --availablebike; } else system.out.println("sorry bike's not available choose another"); } else system.out.println("sorry bikes not available @ time"); } else if(choice.charat(0)=='b') { system.out.println("the following bikes not available:\n"); for(int b = 0; b <= numbikes - 1; b++) if(available [b]== false) system.out.println(" bike no:" + (b+1)); system.out.println("enter bike number want return"); int bikeno=scan.nextint(); scan.nextline(); if(available[bikeno-1]==false) { available[bikeno-1]=true; system.out.println("enter out time"); returningtime[bikeno-1]=scan.nextline(); system.out.println("enter cost total"); calculatecost[bikeno-1]=scan.nextint(); scan.nextline(); system.out.println("total is:"+calculatecost[bikeno-1]); calculatecost[bikeno-1]=0; ++availablebike; } else system.out.println("sorry error"); } } while(!(choice.equals("zzz"))); } }
Comments
Post a Comment