Milkman Bill Calculator Project Extension
/**
* Project Extension
* I would like to implement the following features in this project.
*/
import java.util.*;
class ExtentionOfMilkMenBill
{
Scanner sc = new Scanner(System.in);
int userChoice=0;
float amountToBePaid=0.0F;
public void dairyProductMenu()
{
System.out.println("\t\t\t\t\t ================ Dairy Product ================ ");
System.out.println("\t\t\t\t\t Press 1 For To Butter.");
System.out.println("\t\t\t\t\t Press 2 For To Cheese");
System.out.println("\t\t\t\t\t Press 3 For To Paneer");
System.out.println("\t\t\t\t\t Press 4 For To Exit");
System.out.println("\t\t\t\t\t ========================================== ");
System.out.print("\t\t\t\t\t Enter Your Choice = ");
userChoice = sc.nextInt();
if(userChoice>4 || userChoice<1){
System.out.println("\n\t\t\t\t\t Incorrect Choice ");
dairyProductMenu();
}
else{
operateMenu(userChoice);
}
}
public void operateMenu(int userChoice){
switch(userChoice){
case 1 : sellButter();
dairyProductMenu();
break;
case 2 : sellCheese();
dairyProductMenu();
break;
case 3 : sellPaneer();
dairyProductMenu();
break;
case 4 : exitMessage();
}
}
public void sellButter(){
System.out.print("\t\t\t\t\t Please Enter Quntity In Gram :");
float qty = sc.nextFloat();
System.out.print("\n\t\t\t\t\t Please Enter Rate Per Kg :");
float rate = sc.nextFloat();
float ratePerGram = (rate/1000.0F);
if(qty>0 && rate >0){
amountToBePaid = qty * ratePerGram;
System.out.print("\n\t\t\t\t\t Amount to be paid :"+ amountToBePaid);
System.out.println();
}
else{
System.out.print("\n\t\t\t\t\t Please Enter Valid Value\n");
dairyProductMenu();
}
}
public void sellCheese(){
System.out.print("\t\t\t\t\t Please Enter Quntity In Gram :");
float qty = sc.nextFloat();
System.out.print("\n\t\t\t\t\t Please Enter Rate Per Kg :");
float rate = sc.nextFloat();
float ratePerGram = (rate/1000.0F);
if(qty>0 && rate >0){
amountToBePaid = qty * ratePerGram;
System.out.print("\n\t\t\t\t\t Amount to be paid :"+ amountToBePaid);
System.out.println();
}
else{
System.out.print("\n\t\t\t\t\t Please Enter Valid Value\n");
dairyProductMenu();
}
}
public void sellPaneer(){
System.out.print("\t\t\t\t\t Please Enter Quntity In Gram :");
float qty = sc.nextFloat();
System.out.print("\n\t\t\t\t\t Please Enter Rate Per Kg :");
float rate = sc.nextFloat();
float ratePerGram = (rate/1000.0F);
if(qty>0 && rate >0){
amountToBePaid = qty * ratePerGram;
System.out.print("\n\t\t\t\t\t Amount to be paid :"+ amountToBePaid);
System.out.println();
}
else{
System.out.print("\n\t\t\t\t\t Please Enter Valid Value\n");
dairyProductMenu();
}
}
public void exitMessage(){
System.out.println("\t\t\t\t\t Thank You Visit Again");
}
public static void main(String args[]){
ExtentionOfMilkMenBill ob = new ExtentionOfMilkMenBill() ;
ob.dairyProductMenu();
}
}
No comments:
New comments are not allowed.