0
C++ do while
A supermarket has launched a campaign offering a 15% discount on 3 items. Write a program that takes the total price for every purchase as input and outputs the relevant discount. Sample Input 15000 4000 6700 Sample Output 2250 600 1005 Explanation 2250 represents a 15% Attempt in comments
9 Answers
+ 2
/*
Mando
I believe the problem you have is you have hard coded the sample.
The challenge will test against 3 different item prices, so you will need to do something like this:*/
#include <iostream>
using namespace std;
int main() {
int a,b,c;
cin >>a>>b>>c;
cout<<a;
cout<<b;
cout<<c;
return 0;
}
/*
This is just a snippet to show how to incorporate 3 different inputs*/
+ 2
#include <iostream>
using namespace std;
int main()
{
//int purchaseAmount = 0;
// int totalPrice;
int a;
int ctr=0;
do {
cin>>a;
cout << a*15/100<<endl;
ctr++;
} while(ctr<3);
//your code goes here
return 0;
}
//Check now
0
#include <iostream>
using namespace std;
int main()
{
int purchaseAmount = 0;
int totalPrice;
int a = 15000;
int b = 4000;
int c = 6700;
do {
cout << a b c<< endl;
a++;
} while(a >2250);
//your code goes here
return 0;
}
Very confused about this equation.
0
#include <iostream>
using namespace std;
int main()
{
//int purchaseAmount = 0;
// int totalPrice;
int a = 15000;
int b = 4000;
int c = 6700;
int ctr=1;
do {
cout << a*15/100<< endl<<b*15/100<<endl<<c*15/100;
ctr++;
} while(ctr==1);
//your code goes here
return 0;
}
0
Please check
0
Didnt work
0
Post the full description of question
0
A supermarket has launched a campaign offering a 15% discount on 3 items.
Write a program that takes the total price for every purchase as input and outputs the relevant discount.
Sample Input
15000
4000
6700
Sample Output
2250
600
1005
Explanation
2250 represents a 15% discount for a 15000 purchase; 600 for 4000 and 1005 for 6700 accordingly.
0
#include <iostream>
using namespace std;
int main()
{
double purchaseAmount;
int totalPrice;
int x = 3;
//your code goes here
do {
cin >> totalPrice;
purchaseAmount = totalPrice * 0.15;
cout << purchaseAmount << endl;
x--;
} while(x > 0);
return 0;
}