Algorithm Training P1101

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.