Advertisement
Guest User

SalineCamera.java

a guest
Dec 17th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. public class SalineCamera{
  2.    public static void main(String[] args){
  3.       //Declare and initialize variables
  4.       double cost8 = 2.50, cost5 = 1.22, costWallet = 0.33;
  5.       int qty8 = 4, qty5 = 5, qtyWallet = 50;
  6.      
  7.       //Calculate the total cost for each "package"
  8.       double totCost8 = cost8 * qty8;
  9.       double totCost5 = cost5 * qty5;
  10.       double totCostWallet = costWallet * qtyWallet;
  11.      
  12.       //Calculate the entire cost
  13.       double totCost = totCost8 + totCost5 + totCostWallet;
  14.      
  15.       //Calculate the average
  16.       double average = totCost / (qty8 + qty5 + qtyWallet);
  17.      
  18.       //Output
  19.       System.out.println("Item\tunit cost\tqty\tcost");
  20.       System.out.println("8x10\t$" + cost8 + "\t\t\t" + qty8 + "\t\t$" + totCost8);
  21.       System.out.println("5x7\t$" + cost5 + "\t\t\t" + qty5 + "\t\t$" + totCost5);
  22.       System.out.println("Wallet\t$" + costWallet + "\t\t\t" + qtyWallet + "\t\t$" + totCostWallet);
  23.       System.out.println("Total\t\t\t\t\t\t\t$" + totCost);
  24.       System.out.println("Average\t\t\t\t\t\t$" + average);
  25.    }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement