You are encouraged to form a team of 2 or 3 to work on this homework. Each team
ID: 3907364 • Letter: Y
Question
You are encouraged to form a team of 2 or 3 to work on this homework. Each team submits only one copy of the homework. Submit your homework on Blackboard before the deadline. No late homework is accepted. In this homework, you will re-implement the program that tabulates the sticker price, net price, and discount rate of selected Massachusetts colleges listed in P.20 of the text. Discount rate is defined as Net Price ount Rate 1-Sticker Price When tabulating the data, you will mark the colleges with a discount rate in the range of [50%,60%) with *, and colleges with a discount rate greater than 60% with **. Thus your output will be similar to the following table. Sticker Price Net Price % Discount Rate College Amherst College Harvard University* Hellenic College-Holy Cross** Massachusetts Institute of Technology Saint John's Seminary** Wellesley College* Williams College** Average $40,862 $38,415 $19,503 $39,212 $17,574 $18,277 $6,738 $20,660 57 52 65 47 $13,750 $39,666 $41,434 $33,263 $2,650 $18,400 $16,493 $14,399 81 54 60 60 Note: "Average" should not be marked with asterisks. Implementation Requirement Your implementation must use a 1-D array of stringt] type to store colleage names, and a 2-D array of double[][] type to store sticker price and net price. In addition, the program must include three methods with the following specified signatures: e void main(String[] args). Declares and initializes variables; calls the other two methods; computes the averages. Note: you must use a loop to iterate through the arraysExplanation / Answer
import java.io.*;
public class DemoDisplay{
public static void main(String[] args){
double totalSticker = 0;
double totalNet = 0;
double totalDiscount = 0;
System.out.printf("%-30s %15s %15s %20s ","College","Sticker Price", "Net Price","% Discount Rate");
totalSticker = totalSticker + 40862;
totalNet = totalNet + 17574;
totalDiscount = totalDiscount + (1.0-(17574.0/40862.0))*100;
System.out.printf("%-30s %15s %15s %20.2f ","Amherst College", "$40,862","$17,574",(1.0-(17574.0/40862.0))*100);
totalSticker = totalSticker + 38415;
totalNet = totalNet + 18277;
totalDiscount = totalDiscount + (1.0-(18277.0/38415.0))*100;
System.out.printf("%-30s %15s %15s %20.2f ","Harvard University", "$38,415","$18,277",(1.0-(18277.0/38415.0))*100);
totalSticker = totalSticker + 19503;
totalNet = totalNet + 6378;
totalDiscount = totalDiscount + (1.0-(6378.0/19503.0))*100;
System.out.printf("%-30s %15s %15s %20.2f ","Hellenic College-Holy Cros", "$19,503","$6,378",(1.0-(6378.0/19503.0))*100);
totalSticker = totalSticker + 39212;
totalNet = totalNet + 20660;
totalDiscount = totalDiscount + (1.0-(20660.0/39212.0))*100;
System.out.printf("%-30s %15s %15s %20.2f ","Massachusetts Institute of", "$39,212","$20,660",(1.0-(20660.0/39212.0))*100);
System.out.printf("%-30s ","Technology");
totalSticker = totalSticker + 13750;
totalNet = totalNet + 2650;
totalDiscount = totalDiscount + (1.0-(2650.0/13750.0))*100;
System.out.printf("%-30s %15s %15s %20.2f ","Saint John's Seminary", "$13,750","$2,650",(1.0-(2650.0/13750.0))*100);
totalSticker = totalSticker + 39666;
totalNet = totalNet + 18400;
totalDiscount = totalDiscount + (1.0-(18400.0/39666.0))*100;
System.out.printf("%-30s %15s %15s %20.2f ","Wellesley College", "$39,666","$18,400",(1.0-(18400.0/39666.0))*100);
totalSticker = totalSticker + 41434;
totalNet = totalNet + 16493;
totalDiscount = totalDiscount + (1.0-(16493.0/41434.0))*100;
System.out.printf("%-30s %15s %15s %20.2f ","Williams College", "$41,434","$16,493",(1.0-(16493.0/41434.0))*100);
System.out.printf("%-30s %15.2f %15.2f %20.2f ","Average", totalSticker/7.0,totalNet/7.0,totalDiscount/7.0);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.