当前位置:网站首页>Pta:7-58 Book audio-visual rental management
Pta:7-58 Book audio-visual rental management
2022-06-23 04:38:00 【Sy_ Faker】
A book and video store rents books and tapes .
Give the following framework for a base class :
class Publication
{
protected:
string title;// name
float price;// The original price
int day;// Lease term
public:
virtual void display()=0;// Print price list
}
With Publication Base class , structure Book and Tape class .
Generate the above class and write the main function , The main function is required to have a base class Publication Pointer array , Array elements do not exceed 10 individual .
Publication pp[10];
The main function is based on the input information , Corresponding establishment Book, Tape Class object .
Their original rent is : Lease term 1.2.
in addition , The actual rent charged does not exceed 2 Times the rental valuation .
Book Our valuation is : Old and new * The original price .
Tape Our valuation is : The original price /(1+ Number of rentals /3).
Input format : One line per test case , The first item is the type of rent ,1 by Book,2 by Tape. Next is the name 、 The original price 、 Lease term . Last item Book Is the degree of newness (0.1 to 1),Tape Is the number of times it has been rented . With 0 Indicates the end of the input .
Output name required , Original rent ( After the decimal point 1 Decimal place ), If the original rent is greater than 2 Double rent valuation , At the same time, the actual rent that should be charged ( After the decimal point 1 Decimal place ), And marked at the end R.
sample input
1 AAA 19.5 3 0.5
1 BBB 9.5 2 0.1
2 AA 10 2 0
2 DDDD 12.5 2 38
1 FFF 42 3 0.1
0
sample output
AAA 3.6
BBB 2.4 1.9 R
AA 2.4
DDDD 2.4 1.8 R
FFF 3.6
#include<iostream>
using namespace std;
class Publication
{
protected:
string title;// name
float price;// The original price
int day;// Lease term
public:
Publication()
{
;
}
Publication(string n,float p,int d)
{
title=n;
price=p;
day=d;
}
virtual void display()=0;// Print price list
};
class Book:public Publication
{
double k;
public:
Book(string n,float p,int d,double q):Publication(n,p,d)
{
k=q;
}
virtual void display()
{
cout<<title<<" ";
printf("%.1f",day*1.2);
if(day*1.2>price*k*2)
printf(" %.1f R",price*k*2);
cout<<endl;
}
};
class Tape:public Publication
{
int k;
public:
Tape(string n,float p,int d,int q):Publication(n,p,d)
{
k=q;
}
virtual void display()
{
cout<<title<<" ";
printf("%.1f",day*1.2);
if(day*1.2>(price/(k/3+1))*2)
printf(" %.1f R",(price/(k/3+1))*2);
cout<<endl;
}
};
int main()
{
int type;
cin>>type;
string n;
float p;
int d;
double q1;
int q2;
for(int i=0;type!=0;i++)
{
Publication *pp;
cin>>n>>p>>d;
if(type==1)
{
cin>>q1;
pp=new Book(n,p,d,q1);
}
else
{
cin>>q2;
pp=new Tape(n,p,d,q2);
}
pp->display();
delete pp;
cin>>type;
}
}
边栏推荐
- Imitation 360 desktop suspended ball plug-in
- x24Cxx系列EEPROM芯片C语言通用读写程序
- Sequence table lookup
- 语料库数据处理个案实例(词性赋码、词性还原)
- QMainWindow
- Pta:6-33 student ranking table (destructor)
- 顺序表查找
- Software development in 2022: five realities CIOs should know
- How to ensure application security
- 12 excellent practices of wireless network security
猜你喜欢
随机推荐
Pta:6-33 student ranking table (destructor)
svg d3. JS generate tree tree view
Particle animation background login page particles js
What are the characteristics of SRM supplier management system developed by manufacturing enterprises
【二叉樹進階】AVLTree - 平衡二叉搜索樹
PTA:7-61 师生信息管理
leetcode 91. Decode Ways 解码方法(中等)
PTA:7-69 数据的间距问题
3D数学基础[十六] 匀加速直线运动的公式
Deploying Apache pulsar on kubesphere
PTA:6-29 虚基类的应用-人与教师学生
What is metadata
【深度学习】深度学习推理框架 TensorRT MNN OpenVINO ONNXRuntime
Introduction and use of MySQL view
P1347 sorting (TOPO)
给你的AppImage创建桌面快捷方式
Online text filter less than specified length tool
深度学习 TensorFlow入门
Prince language on insect date class
What is the open source database under Linux









