Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.20 KB | None | 0 0
  1. import java.util.*;
  2. class PricingTool{
  3. static Scanner scan = new Scanner(System.in);
  4. static double totalCost = 0.0;
  5. static double totalClientCost = 0.0;
  6. static String staffingProposal = "";
  7.  
  8. static double consultantHourlyRate = 35.00;
  9. static double seniorConsultantHourlyRate = 55.00;
  10. static double managerHourlyRate = 65.00;
  11. static double seniorManagerHourlyRate = 75.00;
  12. static double principalHourlyRate = 100.00;
  13.  
  14. static double consultantHourlyBillRate = 135.00;
  15. static double seniorConsultantHourlyBillRate = 155.00;
  16. static double managerHourlyBillRate = 165.00;
  17. static double seniorManagerHourlyBillRate = 175.00;
  18. static double principalHourlyBillRate = 200.00;
  19. public static int displayMenu(){
  20. System.out.println("Please choose from one of the following menu options -");
  21. System.out.println("1) Display levels and hourly rates of consultants");
  22. System.out.println("2) Display levels and hourly bill rates of consultants");
  23. System.out.println("3) Staff project");
  24. System.out.println("4) Display project staffing proposal");
  25. System.out.println("5) Calculate profit");
  26. System.out.println("9) Submit project staffing proposal and exit");
  27. System.out.print("Option: ");
  28. return scan.nextInt();
  29. }
  30. public static void displayHourlyRates(){
  31. System.out.println("Levels and Hourly Rates");
  32. System.out.println("---------------------------------------");
  33. System.out.printf("%-20s%10s\n","Employee Level","Hourly Rate");
  34. System.out.println("=============================================");
  35. System.out.printf("%-20s$%-10.2f\n","Consultant",consultantHourlyRate);
  36. System.out.printf("%-20s$%-10.2f\n","Senior Consultant",seniorConsultantHourlyRate);
  37. System.out.printf("%-20s$%-10.2f\n","Manager",managerHourlyRate);
  38. System.out.printf("%-20s$%-10.2f\n","Senior Manager",seniorManagerHourlyRate);
  39. System.out.printf("%-20s$%-10.2f\n","Principal",principalHourlyRate);
  40. }
  41. public static void displayHourlyBillRates(){
  42. System.out.println("Levels and Hourly Bill Rates");
  43. System.out.println("---------------------------------------");
  44. System.out.printf("%-20s%10s\n","Employee Level","Hourly Rate");
  45. System.out.println("=============================================");
  46. System.out.printf("%-20s$%-10.2f\n","Consultant",consultantHourlyBillRate);
  47. System.out.printf("%-20s$%-10.2f\n","Senior Consultant",seniorConsultantHourlyBillRate);
  48. System.out.printf("%-20s$%-10.2f\n","Manager",managerHourlyBillRate);
  49. System.out.printf("%-20s$%-10.2f\n","Senior Manager",seniorManagerHourlyBillRate);
  50. System.out.printf("%-20s$%-10.2f\n","Principal",principalHourlyBillRate);
  51. }
  52. public static double getHoursPerWeek(){
  53. System.out.print("How many hours per week? ");
  54. return scan.nextDouble();
  55. }
  56. public static void updateTotalCost(int num, double hours, double rate){
  57. totalCost += rate * num * hours;
  58. System.out.printf("The current employee cost with an hourly rate of $%.2f is $%.2f\n",rate,totalCost);
  59. }
  60. public static void updateTotalClientCost(int num, double hours, double rate){
  61. totalClientCost += rate * num * hours;
  62. System.out.printf("The current cost to the client with an hourly bill rate of $%.2f is $%.2f\n",rate,totalClientCost);
  63. }
  64. public static void staffProject(){
  65. int num = 0;
  66. double hours = 0.0;
  67. do{
  68. System.out.println("How do you want to staff your project?");
  69. System.out.println("Enter 1 for Consultant");
  70. System.out.println("Enter 2 for Senior Consultant");
  71. System.out.println("Enter 3 for Manager");
  72. System.out.println("Enter 4 for Senior Manager");
  73. System.out.println("Enter 5 for Principal");
  74. System.out.println("Enter any other number when done.");
  75. System.out.print("Level: ");
  76. int level = scan.nextInt();
  77. switch(level){
  78. case 1:
  79. System.out.print("How many Consultants would you like to staff? ");
  80. num = scan.nextInt();
  81. hours = getHoursPerWeek();
  82. staffingProposal += num + " Consultant(s) at " + hours + " hours per week\n";
  83. updateTotalCost(num,hours,consultantHourlyRate);
  84. updateTotalClientCost(num,hours,consultantHourlyBillRate);
  85. break;
  86. case 2:
  87. System.out.print("How many Senior Consultants would you like to staff? ");
  88. num = scan.nextInt();
  89. hours = getHoursPerWeek();
  90. staffingProposal += num + " Senior Consultant(s) at " + hours + " hours per week\n";
  91. updateTotalCost(num,hours,seniorConsultantHourlyRate);
  92. updateTotalClientCost(num,hours,seniorConsultantHourlyBillRate);
  93. break;
  94. case 3:
  95. System.out.print("How many Managers would you like to staff? ");
  96. num = scan.nextInt();
  97. hours = getHoursPerWeek();
  98. staffingProposal += num + " Manager(s) at " + hours + " hours per week\n";
  99. updateTotalCost(num,hours,managerHourlyRate);
  100. updateTotalClientCost(num,hours,managerHourlyBillRate);
  101. break;
  102. case 4:
  103. System.out.print("How many Senior Managers would you like to staff? ");
  104. num = scan.nextInt();
  105. hours = getHoursPerWeek();
  106. staffingProposal += num + " Senior Manager(s) at " + hours + " hours per week\n";
  107. updateTotalCost(num,hours,seniorManagerHourlyRate);
  108. updateTotalClientCost(num,hours,seniorManagerHourlyBillRate);
  109. break;
  110. case 5:
  111. System.out.print("How many Principals would you like to staff? ");
  112. num = scan.nextInt();
  113. hours = getHoursPerWeek();
  114. staffingProposal += num + " Principal(s) at " + hours + " hours per week\n";
  115. updateTotalCost(num,hours,principalHourlyRate);
  116. updateTotalClientCost(num,hours,principalHourlyBillRate);
  117. break;
  118. }
  119. if(level>5 || level<1)
  120. break;
  121. }while(true);
  122. }
  123. public static double calculateProfit(){
  124. System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  125. System.out.printf("Your total cost of employee salaries per week is: $%.2f\n",totalCost);
  126. System.out.printf("Your total cost to the client per week is: $%.2f\n",totalClientCost);
  127. System.out.printf("Your profit per week is: $%.2f\n",(totalClientCost - totalCost));
  128. System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  129. return (totalClientCost - totalCost);
  130. }
  131. public static void displayProjectStaffingProposal(){
  132. System.out.println("Your project will be staffed as follows:\n");
  133. System.out.println(staffingProposal);
  134. }
  135. public static void main(String[] args) {
  136. System.out.println("Welcome to the Pricing Tool");
  137. while(true){
  138. int option = displayMenu();
  139. switch(option){
  140. case 1:
  141. displayHourlyRates();
  142. break;
  143. case 2:
  144. displayHourlyBillRates();
  145. break;
  146. case 3:
  147. staffProject();
  148. break;
  149. case 4:
  150. displayProjectStaffingProposal();
  151. break;
  152. case 5:
  153. double s = calculateProfit();
  154. break;
  155. case 9:
  156. System.out.println("You have successfully submitted your project proposal. Good-bye!");
  157. break;
  158. default:
  159. System.out.println("Incorrect menu option. please try again");
  160. }
  161. if(option == 9)
  162. break;
  163. }
  164. }
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement