当前位置:网站首页>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;
}
}
边栏推荐
- Halcon胶线检测—模板匹配、位姿变换、胶宽,胶连续性检测
- QMainWindow
- Online JSON to CSharp (c) class tool
- 最新编程语言排行榜
- PTA:7-85 数据的间距问题(重载+函数模板)
- 语料库数据处理个案实例(词性赋码、词性还原)
- X24cxx series EEPROM chip C language universal reading and writing program
- svg d3. JS generate tree tree view
- [pytoch] calculate the derivative of sin (x) by automatic differentiation
- Pta:7-37 student number analysis
猜你喜欢

最新编程语言排行榜

LabVIEW displays both hexadecimal and normal characters in the same table

LabVIEW在同一表中同时显示十六进制字符和普通字符

基于FPGA的VGA协议实现

Sessions and Daemons
![[pytoch] calculate the derivative of sin (x) by automatic differentiation](/img/a7/16dd9ecc13a986a9141ecc3fba00a1.png)
[pytoch] calculate the derivative of sin (x) by automatic differentiation

Pytoch --- pytoch customizes the dataset
![[multimode] unimo](/img/a5/a857e20e1432ef3623527c8655a49a.png)
[multimode] unimo

国家药品不良反应监测中心 ADR 电子传输EDI解决方案

Avltree - arbre de recherche binaire équilibré
随机推荐
2022年起重机械安全管理考试题库及答案
TS进阶之infer
Sequence table lookup
离线数仓建模中常见的概念-术语
How to ensure application security
Pytorch---Pytorch进行自定义Dataset
国家药品不良反应监测中心 ADR 电子传输EDI解决方案
Analysis on the current situation of the Internet of things in 2022
[advanced binary tree] AVLTree - balanced binary search tree
PTA:7-58 图书音像出租管理
leetcode 91. Decode Ways 解码方法(中等)
Does the network disk also roll inside?
How to use shell script to monitor file changes
Common interview questions in automated testing
靜態查找錶和靜態查找錶
Zhongang Mining: the demand for fluorite in the new energy and new material industry chain has increased greatly
After Huawei online battle service players quickly match, different players receive different lists of players in the same room
[从零开始学习FPGA编程-40]:进阶篇 - 设计-竞争与风险Risk或冒险
在线JSON转CSharp(C#)Class工具
解决使用Exception抛出后,@Transactional不生效