Advertisement
MSN69

Home work #1

Feb 18th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.01 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Homework1 {
  4.  
  5. public static void main (String [] Args) {
  6. Scanner read = new Scanner (System.in);
  7.  
  8. /*
  9.  
  10. NOTES:
  11.  
  12.  "l" is length
  13.  "w" is width
  14.  "stotal" is the sum of price and area
  15.  "total" is the sum of all rooms
  16.  
  17.  
  18.  Credits to: Mamoun Salim Nabulsi #11717207
  19.  
  20. */
  21.  
  22. float l1, l2, l3, w1, w2, w3, area1, area2, area3;
  23. float price1, price2, price3;
  24. float stotal1, stotal2, stotal3;
  25. float total;
  26.  
  27.  
  28. System.out.println("Please enter the length and width of room number one");
  29. System.out.println("Length:");
  30. l1 = read.nextFloat();
  31. System.out.println("Width:");
  32. w1 = read.nextFloat();
  33. System.out.println("Please enter the price per meter squared");
  34. price1 = read.nextFloat();
  35. area1 = (l1 * w1);
  36. stotal1 = (price1 * area1);
  37.  
  38.  
  39. System.out.println("Please enter the length and width of room number one");
  40. System.out.println("Length:");
  41. l2 = read.nextFloat();
  42. System.out.println("Width:");
  43. w2 = read.nextFloat();
  44. System.out.println("Please enter the price per meter squared");
  45. price2 = read.nextFloat();
  46. area2 = (l2*w2);
  47. stotal2 = (price2 * area2);
  48.  
  49. System.out.println("Last step. Kindly, enter the length and width of room number one");
  50. System.out.println("Length:");
  51. l3 = read.nextFloat();
  52. System.out.println("Width:");
  53. w3 = read.nextFloat();
  54. System.out.println("Please enter the price per meter squared");
  55. price3 = read.nextFloat();
  56. area3 = (l3*w3);
  57. stotal3 = (price3 * area3);
  58.  
  59.  
  60. total = (stotal1 + stotal2 + stotal3);
  61.  
  62.   System.out.println("Room #\t Length\t Width\t Area\t Price per meter\t Total");
  63.   System.out.println("--------------------------------------------------------------");
  64.   System.out.println("Room #1\t" +l1+"\t" +w1+"\t" +area1+"\t"+price1+ "\t"+stotal1);
  65.   System.out.println("Room #2\t" +l2+"\t" +w2+"\t" +area2+"\t"+price2+"\t"+stotal2);
  66.   System.out.println("Room #3\t" +l3+"\t" +w3+"\t" +area3+"\t"+price3+"\t"+stotal3);
  67.   System.out.println("                                                         Sub Total:"+total);
  68.  
  69.  
  70.  
  71. }
  72.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement