Posted By

AustinGoods on 10/18/18


Tagged


Versions (?)

Grocery Store Example


 / Published in: Java
 

........

  1. public class Stores{
  2.  
  3. public static void main(String []args){
  4.  
  5.  
  6. //Stores of each city
  7.  
  8. //groceryStore houstonStore = new groceryStore();
  9. groceryStore dallasStore = new groceryStore();
  10. // groceryStore huttoStore = new groceryStore();
  11. //groceryStore austinStore = new groceryStore();
  12.  
  13. dallasStore.tvsSoldYearly = 500;
  14. dallasStore.tvPrice = 199.99;
  15. dallasStore.applesSoldYearly = 450;
  16. dallasStore.applePrice = 0.89;
  17.  
  18. double revenueDallas;
  19.  
  20. dallasRevenue = (dallasStore.tvsSoldYearly * dallasStore.tvPrice) + (dallasStore.applesSoldYearly * dallasStore.applePrice);
  21.  
  22. System.out.println("The grocery store in Dallas made $" + dallasRevenue + " from TV and Apple sales in 2016\n");
  23.  
  24. /*huttoStore.tvsSoldYearly = 400;
  25.   huttoStore.tvPrice = 200;
  26.   huttoStore.applesSoldYearly = 450;
  27.   huttoStore.applePrice = 1.29;
  28.  
  29.   huttoRevenue = (huttoStore.tvsSoldYearly * huttoStore.tvPrice) + (huttoStore.applesSoldYearly * huttoStore.applePrice);
  30.  
  31.   System.out.println("The grocery store in Hutto made $" + huttoRevenue + " from TV and Apple sales in 2016\n");
  32.  
  33.   houstonStore.tvsSoldYearly = 520;
  34.   houstonStore.tvPrice = 156.56;
  35.   houstonStore.applesSoldYearly = 450;
  36.   houstonStore.applePrice = 0.76;
  37.  
  38.   houstonRevenue = (houstonStore.tvsSoldYearly * houstonStore.tvPrice) + (houstonStore.applesSoldYearly * houstonStore.applePrice);
  39.  
  40.   System.out.println("The grocery store in Houston made $" + houstonRevenue + " from TV and Apple sales in 2016\n");
  41.  
  42.   austinStore.tvsSoldYearly = 300;
  43.   austinStore.tvPrice = 550;
  44.   austinStore.applesSoldYearlyy = 250;
  45.   austinStore.applePrice = 1.56;
  46.  
  47.   austinRevenue = (austinStore.tvsSoldYearly * austinStore.tvPrice) + (austinStore.applesSoldYearly * austinStore.applePrice);
  48.  
  49.   System.out.println("The grocery store in Austin made $" + austinRevenue + " from TV and Apple sales in 2016\n");
  50.  
  51.   totalRevenue = austinRevenue + houstonRevenue + dallasRevenue + huttoRevenue;
  52.  
  53.   System.out.println("The grocery stores in Houston, Austin, Dallas and Hutto made a combined $" + totalRevenue + " from selling TVs and Apples");*/
  54.  
  55. }
  56.  
  57. public void groceryStore {
  58.  
  59. int tvsSoldYearly;
  60. double tvPrice;
  61. int applesSoldYearly;
  62. double applePrice;
  63.  
  64. }
  65. }

Report this snippet  

You need to login to post a comment.