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

20th Sep 2021, 5:58 AM
Mando
Mando - avatar
9 ответов
+ 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*/
20th Sep 2021, 8:55 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 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
20th Sep 2021, 11:22 AM
Atul [Inactive]
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.
20th Sep 2021, 5:58 AM
Mando
Mando - avatar
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; }
20th Sep 2021, 6:06 AM
Atul [Inactive]
0
Please check
20th Sep 2021, 6:06 AM
Atul [Inactive]
0
Didnt work
20th Sep 2021, 6:07 AM
Mando
Mando - avatar
0
Post the full description of question
20th Sep 2021, 6:22 AM
Atul [Inactive]
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.
20th Sep 2021, 6:23 AM
Mando
Mando - avatar
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; }
21st Sep 2021, 8:26 PM
Cobi
Cobi - avatar