techhipbettruvabetnorabahisbahis forumutaraftarium24edueduseduseduseduseduedueduseduedus Java Program to Calculate Restaurant Bill | Java Programs
Latest :

Java Program to Calculate Restaurant Bill | Java Programs

Java code to calcuate the resturant bill, the following program is pretty simple one along with sample outputs. We have choosen the famous south indian food to create the following program.

We all go to restaurants frequently and eat. Today, let us write a code to calculate the restaurant bill. With multiple items in a restaurant (in our case 10), our menu card with the items and its respective prices are already fixed.

So, two of our input arrays- items s (string) and rate (int) are already declared in the code along with their values. The only variable input is the quantity of these 10 items- qt array(int) that can be taken at runtime with the help of Scanner class in Java.

Since it is convenient to have the list displayed in front of us while placing each order, so we first print the items and their prices in our console screen with serial number, item and rate.

We have 10 choices (0-9) so, we make use of an integer variable (ch) and read the choice value between 0-9 with the use of Scanner class.

Based on the entered choice, the quantity (qt) at that particular choice is incremented by 1.

if(ch>0 && ch<10) {

System.out.println(“enter the no of quantites of “+s[ch-1]);

int q=input.nextInt();

qt[ch-1]+=q; }

If the choice entered is outside the given condition i.e., not in between the 10 values then, the a boolean variable (quit) is made false.

else { quit=false; }

These statements keep repeating until the boolean variable (quit) is made false indicating that the choice entered is outside range telling us that it marks the end of the order and we must exit.

After completion of order, we traverse through the quantity array (qt) till the end, and for every value of qt which is not equal to zero, we multiply the quantity and the rate of the particular item and add this to a variable(sum) which is used to find the entire bill.

for(int i=0;i<10;i++) {

if(qt[i]!=0) {

sum+=qt[i]*rate[i];

System.out.println(s[i]+”* “+qt[i]+”==”+qt[i]*rate[i]+”rs”); } }

We can display the total price of each item and then finally display our total bill (sum) in the console screen.

Java Code Resturant Bill

Output:

techhipbettruvabetnorabahisbahis forumutaraftarium24edusedueduedueduseduseduedusedusedu
x

Check Also

Java Program To Print Ordinal Numbers | Java Porgrams

How to print ordinal numbers in Java – This specific article deals with the code ...

grandpashabetgrandpashabetgrandpashabethttps://mobilebarhawaii.com/ballettea tropazcasibom girişcasibomhacklinkgrandpashabetbets10onwinonwin girişcasibom güncel girişselcuksportshdgrandpashabetholiganbetatakoy escortatakoy escortsisli escortjojobetCasibomtürk pornomaksibetcratosroyalbetdeneme bonusu veren sitelergrandpashabetonwinligobetmavibetJojobetsahabethttps://www.escortbayanlariz.net/betwoonsahabetcasibomcasibom girişÇeşme escortjojobetbakırköy escortdeneme bonusu veren sitelerhalkali escortgrandpashabet girişholiganbetankara escort bayangrandpashabetultrabetgrandpashabet girişholiganbetonwinsahabetbetwoonsahabet girişbetturkeypusulabetextrabetTipobetholiganbetGrandpashabetgrandpashabetesenyurt anal escortSekabetnakitbahiscasibomgrandpashabetİstanbul Escorthttps://www.gvscolombia.com/betebetdeneme bonusu veren sitelerJojobet GirişstarzbetsavoybettingsavoybettingBets10 güncel girişfixbetBetturkey girişcasibom güncel girişkucukcekmece escortzbahissekabetotobetonwinmatbetmatadorbetmarsbahiskingroyalgrandpashabetbetturkeymadridbetsekabetimajbetholiganbetbetvolebetordercasinolevantPadişahbetmavibetbets10meritbetotobetjojobetgrandpashabetholiganbetmarsbahisonwinonwinsahabetsekabetmatbetimajbetsahabet güncel girişbetcupbakırköy escortcanlı bahiscashbackstarzbetmegabahisonwinpin-upperabetromabetcasibom girişcasibom girişcasibom güncel girişjojobet girişCasibomvaycasinomarsbahisperabetperabet güncel girişcasinoroysdeneme bonusu veren sitelerjokerbet güncel girişmarsbahissightcareipv6jojobetjojobetsahabetbets10,bets10 giriş,bets10 güncel giriş1xbet,1xbet girişmarsbahis,marsbahis güncel giriş , marsbahis giriş,marsbahis adresmarsbahis,marsbahis güncel giriş , marsbahis giriş,marsbahis adresmarsbahispradabetvevobahisbetsmovebetsmovegoldenbahismariobetholiganbetmarsbahiscasibomjojobetbets10atlasbetBostancı escort Bağcılar escortvbetonwinmeritking1xbetpusulabetmatbetcasibombets10belugabahisİstanbul EscortDeneme bonusu veren sitelercasibomjojobet girişJojobet Girişbayraklı escortcasibomcasibom girişcasibom güncel girişholiganbetimajbetperabetdeneme bonusu veren siteler 2025vaycasinocasinomaxizbahiscasinometropolzbahisbetturkeyvaycasinoextrabet girişmadridbetsekabet güncel girişonwin girişmatbet girişmarsbahis girişmariobetdeneme bonusu veren sitelermariobetmarsbahiscasibomhiltonbetkingroyalgrandpashabetgrandpashabet güncelbetexperbetexperonwinbahiscomtrendbettipobetartemisbetrestbetfixbetpinbahisbetkanyondinamobetkralbetcratosslotbetebetnakitbahistipobetultrabetcasibom girişholiganbet girişgrandpashabetmarsbahismarsbahisholiganbetholiganbettambetsahabetHoliganbet girişfixbetvaycasinoonwinonwinhttps://sahipleniyorum.com/bets10bets10 girişmegabahismatbetcasibomcasibom girişmaltepe escortcasival girişmecidiyeköy escortdyziypayjojobettipobetbets10casibomtipobetbets10 güncel girişimajbetimajbet girişCasibommavibetmavibet güncelonwin girişotobetotobet girişMavibetcasinomaximarsbahisforum bahiscasibom girişcasibomvaycasino