Mhazard

Java Weight Program

Oct 3rd, 2015
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. // 15101194S
  2.  
  3. //Import Scanner
  4. import java.util.Scanner;
  5. public class WeightProgram
  6. {
  7.         public static void main(String[] args)
  8.         {
  9.                 //Title
  10.                 System.out.println("Weight Program ");
  11.                 //Scanner
  12.                 Scanner sc = new Scanner(System.in);
  13.                 //Insert Apple
  14.                 System.out.print("Enter the number of apple to buy: ");
  15.                 int AppleAmount = sc.nextInt();
  16.                 //Insert Mango
  17.                 System.out.print("Enter the number of mango to buy: ");
  18.                 int MangoAmount = sc.nextInt();
  19.                 //Default Weight
  20.                 int AppleWeight = 103;
  21.                 int MangoWeight = 110;
  22.                 //TotalWeight
  23.                 int TotalWeight = (AppleAmount * AppleWeight) + (MangoAmount * MangoWeight);
  24.                 //Calculation
  25.                 int G100 = TotalWeight / 100;
  26.                 int G50 = TotalWeight %100 /50;
  27.                 int G20 = TotalWeight %100 /20;
  28.                 int G10 = TotalWeight %100 %20 /10;
  29.                 int G5 = TotalWeight %100 %20 %10 /5 ;
  30.                 int G1 = TotalWeight %10 %20 %10 %5 /1;
  31.                 System.out.println("100g-weight:" + G100);
  32.                 System.out.print(" ");
  33.                 System.out.println("50g-weight:" + G50);
  34.                 System.out.print(" ");
  35.                 System.out.println("20g-weight:" + G20);
  36.                 System.out.print(" ");
  37.                 System.out.println("10g-weight:" + G10);
  38.                 System.out.print(" ");
  39.                 System.out.println("5g-weight:" + G5);
  40.                 System.out.print(" ");
  41.                 System.out.println("1g-weight:" + G1);
  42.                 System.out.print(" ");
  43.         }
  44. }
Add Comment
Please, Sign In to add comment