Today’s Special Men
Today’s Special Men in Bakeri.
Problem Statement: Mr. Sharma owns a bakery shop and is quite popular for baking variety of cakes and pastries. Each day he comes up with Today’s Special Menu that includes two special cakes and two special pastries. He prepares Today’s Special Menu every day and puts it for the display. But with every passing day, it has become painful for Mr. Sharma to prepare the hand written menu
JAVA code
package com.company; import java.util.Scanner; public class Main { public static void main(String[] args) { System.out.println(" Tax Calculator App "); System.out.println(" ------WELCOME------"); long MyCT = 0; int j=0; System.out.println("Enter total person count"); Scanner Persons = new Scanner(System.in); int NoOfPersons = Integer.parseInt(Persons.nextLine()); String[] Names = new String[NoOfPersons] ; long[] CT = new long[NoOfPersons]; for (int i=0 ; i<NoOfPersons ; i++) { j++; System.out.println("Enter name "+j); String MyNames = Persons.nextLine(); Names[i] = MyNames; System.out.println("Enter "+Names[i]+"'s Annual Income: "); MyCT = Integer.parseInt(Persons.nextLine()); CT[i] = MyCT; ; } System.out.println(" Names with liable taxes"); System.out.println(" ----------------------------"); Tax(CT, Names, NoOfPersons); } public static void Tax( long[] CT , String[] Names, int NoOfPersons){ for (int i=0; i<NoOfPersons; i++){ if (CT[i]<100000){ System.out.println(Names[i]+": $ 0"); } else if (CT[i]>=100000&&CT[i]<300000){ double Taxes =0.1*CT[i]; System.out.println(Names[i]+": $ "+Taxes); } else if (CT[i]>=300000){ double Taxes =0.2*CT[i]; System.out.println(Names[i]+": $ "+Taxes); } } } }
package com.internshala.javaapp; public class Cake { String name; float price; public String getName() { return name; } public void setName(String name) { this.name = name; } public float getPrice() { return price; } public void setPrice(float price) { this.price = price; } public void display() { System.out.println(" " + name + " : " + '\u20B9' + " " + price + " per pound"); } }package com.internshala.javaapp; public class Pastry extends Cake { @Override public void display() { System.out.println(" " + name + " : " + '\u20B9' + " " + price + " per piece"); } }
Comments
Post a Comment