-->
当前位置:首页 > 题库

PROGRAMMING:Periodical charge

Luz5年前 (2021-05-10)题库408
The post office offers subscriptions to two kinds of Periodicals: magazines and newspapers.
The framework of the following base classes is given
class Periodical
{
protected:
string title; // name
public:
virtual void display()=0;// Printing charge
}
Taking periodic as the base class, we construct magazine and newspaper classes.
Generate the above class and write the main function, which requires that there is a base class periodic pointer array in the main function, with no more than 10 array elements.
Periodical *pp[10];
According to the input information, the main function establishes the magazine and newspaperclass objects. For magazine, it gives the number of subscription periods and the price of each period. For newspaperit gives the number of subscription weeks, weekly publishing times and the price of each period.
Input format: each test case occupies one line, the first item is type, 1 is magazine, 2 is newspaperer, the second item is name, the third item is unit price, the fourth item of magazine is issue number, the fourth item of newspaperer is subscription weeks, and the fifth item is publishing times per week.
When output, print the name and charge of each journal in turn (one decimal place after decimal point).
Input example:
1 AAA 12.8 6
1 BB 15 3
2 CCCC 2.1 16 3
2 DD 0.7 55 7
1 EEE 18 3
0
Output example:
AAA 76.8
BB 45.0
CCCC 100.8
DD 269.5
EEE 54.0






answer:If there is no answer, please comment