Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 15101194S
- //Import Scanner
- import java.util.Scanner;
- public class WeightProgram
- {
- public static void main(String[] args)
- {
- //Title
- System.out.println("Weight Program ");
- //Scanner
- Scanner sc = new Scanner(System.in);
- //Insert Apple
- System.out.print("Enter the number of apple to buy: ");
- int AppleAmount = sc.nextInt();
- //Insert Mango
- System.out.print("Enter the number of mango to buy: ");
- int MangoAmount = sc.nextInt();
- //Default Weight
- int AppleWeight = 103;
- int MangoWeight = 110;
- //TotalWeight
- int TotalWeight = (AppleAmount * AppleWeight) + (MangoAmount * MangoWeight);
- //Calculation
- int G100 = TotalWeight / 100;
- int G50 = TotalWeight %100 /50;
- int G20 = TotalWeight %100 /20;
- int G10 = TotalWeight %100 %20 /10;
- int G5 = TotalWeight %100 %20 %10 /5 ;
- int G1 = TotalWeight %10 %20 %10 %5 /1;
- System.out.println("100g-weight:" + G100);
- System.out.print(" ");
- System.out.println("50g-weight:" + G50);
- System.out.print(" ");
- System.out.println("20g-weight:" + G20);
- System.out.print(" ");
- System.out.println("10g-weight:" + G10);
- System.out.print(" ");
- System.out.println("5g-weight:" + G5);
- System.out.print(" ");
- System.out.println("1g-weight:" + G1);
- System.out.print(" ");
- }
- }
Add Comment
Please, Sign In to add comment