write in c++ program: An incredulous buyer counts the total amount of purchases
ID: 3848112 • Letter: W
Question
write in c++ program:
An incredulous buyer counts the total amount of purchases in kopecks. But, coming to the cashier, it is difficult for him to understand how many rubles and kopecks he must pay. Write a program that will help him. Input One integer from the range of 1..1 million - purchase amount in kopecks. Imprint: It is necessary to issue a record of how much rubles and kopecks the buyer should pay. In doing so, you must follow the following rules:
1. The words "ruble" and "kopeck" must be agreed with the numerals. For example: "1 ruble", but "5 rubles", "1 kopek", but "23 kopecks."
Explanation / Answer
using namespace std;
#include<iostream>
int main(){
int ruble,kopeck;
int n;
cout<<" enter total amount in kopecks (1 to 1 million): ";
cin>>n;
cout<<" Total Amount : ";
if(n>100){
ruble=n/100;
kopeck=n%100;
}
else{
kopeck=n;
}
if(ruble==1){
cout<<ruble<<" RUBLE ";
}
if(ruble>1){
cout<<ruble<<" RUBLES ";
}
if(kopeck==1){
cout<<kopeck<<" KOPECK ";
}
if(kopeck>1){
cout<<kopeck<<" KOPECKS ";
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.