0

Can someone please help me out with the practice exercise 7.2 "What's My Discount" in C++. I'm lost as Adam's house cat here. 🤯

I just don't have a clue as to what I'm doing. Arrays are my weak point anyway and this exercise isn't inspiring my confidence at all.

31st Jan 2021, 2:30 AM
Michael Maxwell
Michael Maxwell - avatar
9 ответов
+ 2
What is the practice goal & instruction? Did it say it was necessary to use arrays? if not, then maybe you can think of other ways to get through.
31st Jan 2021, 2:50 AM
Ipang
+ 2
Get your input as a double (make sure p is a double in the formula). Then loop over each element in the array and output the result (make sure the output will result in a double). Make sure that all your outputs are on the same line separated by a space. (You may not need the space after the last element)
1st Feb 2021, 9:02 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
7.2 is "Taking input" "What's my discount" is 29.2 So which is it? I'm guessing you meant 29.2 because 7.2 has nothing to do with arrays, since they haven't even been talked about at that point. Anyway, non pro users can't see the practice exercise so I don't know what is being asked in the challenge.
31st Jan 2021, 2:57 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Ipang, I can't get back to the response you sent, so I'll just post the information here. You are given an array of doubles of items in a store that have different prices (see template). Write a program that takes the "percent off" discount as input and outputs discounted item prices on one line in the same sequence you are given, separated by a space (" "). Sample Input 25 Sample Output 375 9.3 70.5 33.75 2.25 60.75 750.675 63.75 67.5 0.75 26.25
1st Feb 2021, 7:08 PM
Michael Maxwell
Michael Maxwell - avatar
+ 1
Thanks for the insight. I'll put it to use.
1st Feb 2021, 11:01 PM
Michael Maxwell
Michael Maxwell - avatar
0
To get a discounted price use the formula: a – a*p/100, where a is the initial price and p is the discount percent off.
1st Feb 2021, 7:08 PM
Michael Maxwell
Michael Maxwell - avatar
0
#include <iostream> using namespace std; int main() { double items[] = {500, 12.4, 94, 45, 3, 81, 1000.9, 85, 90, 1, 35}; //your code goes here return 0; }
1st Feb 2021, 7:08 PM
Michael Maxwell
Michael Maxwell - avatar
0
Michael I left the discussion because it was idle for 2 days. I just saw your DM. Just as an FYI, DM isn't working for me, I can only read, no reply.
14th Feb 2021, 2:10 PM
Ipang
0
Yeah, these guys aren't on the ball like Facebook, huh😂😅🤣
14th Feb 2021, 10:45 PM
Michael Maxwell
Michael Maxwell - avatar