Algorithm Training P1101time limit: 1.0s memory limit: 256.0MB
There is a bill of lading whose data items are: Product name (MC), Unit Price (DJ), Quantity (SL). Defines a struct prut whose members are the three data above. Define a struct-body array of type Prut in the main function, enter the value of each element, and calculate and output the total amount of the bill of lading.
Input format: The first line is the number of data items N (n<100), followed by each row is a data item. The product name is a string that is not more than 100 in length, the unit price is double, and the quantity is integer type.
Output format: The total amount of the double type.
Input:
4
Book 12.5 3
Pen 2.5 10
Computer 3200 1
Flower 47 5
Output:
3497.500000
class Prut { String MC; Double DJ; int SL; public Prut (String MC,double DJ,int SL) { this. mc=MC; this. dj=DJ; this. sl=SL; }}
ImportJava.util.Scanner; Public classMain { Public Static voidMain (string[] args) {//TODO auto-generated Method StubScanner sc=NewScanner (system.in); while(Sc.hasnext ()) {intn=Sc.nextint (); prut[] PR=NewPrut[n+1]; for(inti=0;i<n;i++) {String T1=Sc.next (); DoubleT2=sc.nextdouble (); intt3=Sc.nextint (); Pr[i]=NewPrut (T1,T2,T3); } Doubleans=0.0; for(inti=0;i<n;i++) {ans+=pr[i]. dj*PR[I].SL; } System.out.printf ("%.6f", ans); } sc.close (); }}
Algorithm Training P1101