Похожие чаты

When we run this program, given input gets overwrite on

the previous given input in console.
how to can we get input in new lines without overwriting the previous one ?

// Program to make a tollBooth class
const char ESC=27;
const double toll= 0.5;


class tollBooth{
unsigned int total_cars;
double money;
public:
tollBooth():total_cars(0),money(0){}
void pay_cars(){
total_cars++;
money+=toll;
}
void non_pay_cars(){
total_cars++;
}
void display(){
cout<<"Number of paying cars: "<<total_cars<<endl
<<"Number of amount collected: "<<money<<" cents"<<endl;
}

};

int main(){
tollBooth booth1;
char ch;

cout<<"\nPress 0 for paying car\nPress 1 for non paying cars\nPress ESC to exit program"<<endl;
do{
ch = getche();
if(ch=='0'){
booth1.pay_cars();
}
if(ch=='1'){
booth1.non_pay_cars();
}
}while(ch!=ESC);
booth1.display();
return 0;
}

1 ответов

8 просмотров

Don't use functions from the conio header.

Похожие вопросы

Обсуждают сегодня

Ясн. Но я всеравно к кедам отношусь с опасением. Чисто субьективное кедосозерцание. Что касаемо "восторга изяшности кед" так и не вкурил, хотя много слышал, пока не поставил с...
Артем Записной
30
They keep hyping $FUN but where's the progress? 🙄
Noah Noure
23
Btw guys very stupid question but i haven't researchd so js asking you pros . Can ltc be traced too? Literally point to pint to the user? And getting the banks blocked ? Exch...
20
type TObj = object procedure Init; virtual; end; TObj1 = object(TObj) procedure Init; override; end; procedure TObj1.Init; begin inherited; end; procedur...
Alexander 👋
29
Есть какой-нибудь для Delphi/FPC T*Compression(Decompression)Stream на базе LZ4/Zstd/любой другой быстрый(и хорошо сжимающий) алгоритм А ещё лучше в pure pascal А ещё лучше од...
notme
48
А чем вам питонисты не угодили?😂
.
79
Hey guys, did you see the new announcement about $Fun? 🔥
Filip Murphy
55
How can a minority hashrate chain defend from a fork-hopping ASIC miner? The problem: 1. A miner comes into your network, and mines at 60-70% hashrate. 2. After some time, th...
Kishniev
13
yeap, thanks guys for response, but I really like to understand does a pool created on curve.fi has the option or api or I can call a function of a smart contract to set excha...
Oleg Karoza
11
Hey people, how do I unstake from the old pool and stake in the new pool??
Dyldo Baggins
24
Карта сайта