0

Someone Help me on this assignment in c++

Basically I'm making a sales tax calculator you can say, search up "step function and discontinous function - algebra class" Look at examples 2 and its solution I want to make it like that, it will be simple for someone like an advanced c++ or intermediate level but for me its not. Look at how I did it but for some reason my teacher isnt accepting it since its not correct. https://code.sololearn.com/cB8oUETKz8H6/?ref=app If you have question let me know

10th Mar 2021, 6:30 PM
boba
boba - avatar
20 Answers
+ 2
Its not my explanation I got this from a website
10th Mar 2021, 8:24 PM
boba
boba - avatar
+ 2
AFAIK - Parentheses are not used for && conditions - There is no use of else if / else 🙂
12th Mar 2021, 6:06 AM
Sanjay Kamath
Sanjay Kamath - avatar
+ 2
Its already solved everyone thank you Martin Taylor
12th Mar 2021, 5:08 PM
boba
boba - avatar
+ 1
Martin Taylor thanks much quick question why did you put a nested if statement? Would it work with just one if and multiple else if
11th Mar 2021, 10:44 PM
boba
boba - avatar
0
Okay ill try to do that then
10th Mar 2021, 7:03 PM
boba
boba - avatar
0
Martin Taylor sorry I was providing explanation in this block comment but this code is coming from visual studio
10th Mar 2021, 7:14 PM
boba
boba - avatar
10th Mar 2021, 7:25 PM
boba
boba - avatar
0
I just want it to be like under solution in #2
10th Mar 2021, 8:17 PM
boba
boba - avatar
0
I split two primary examples on how to code it ignore the first one i took it out in the block comment
10th Mar 2021, 8:18 PM
boba
boba - avatar
0
I wish i can show you a screenshot but thats how they want it to be
10th Mar 2021, 8:30 PM
boba
boba - avatar
0
Look ill show you another example .55 * 30 = 16.5 16.5 = 16 + .5 Tax = (.05 * 16) + .03 = .83 16.5 + .83 = 17.33
10th Mar 2021, 8:34 PM
boba
boba - avatar
0
But I need if statements look at the link
10th Mar 2021, 9:30 PM
boba
boba - avatar
0
Under example 2
10th Mar 2021, 9:31 PM
boba
boba - avatar
0
Hey martin my bad
12th Mar 2021, 2:02 AM
boba
boba - avatar
0
Wym? Sanjay Kamath I already solved the problem but uh?
12th Mar 2021, 6:45 AM
boba
boba - avatar
0
boba Using else if makes the code more efficient. Suppose that there are 10 if statements, of which a single condition is to be checked. Using 'else if' causes the compiler to skip the rest if the first one is true. Of course, that doesn't matter here.
12th Mar 2021, 2:55 PM
Calvin Thomas
Calvin Thomas - avatar
0
Hey used missed ';' in your code at the end of both 'cout' commands and variable name is also incorrect in cin You have written unitcost and declared variable name is unitscost.
12th Mar 2021, 3:22 PM
Nishant Prateek
Nishant Prateek - avatar
0
Yes because it has few syntax errors as well as variable name at 11 line is not correct it misses 's' for 'unitscost' So maybe because of this teacher is not accepting it, let me know if I am wrong.
12th Mar 2021, 5:36 PM
Manjeet Sinha
Manjeet Sinha - avatar