I am completely stumped with a programming issue. Let me be clear, I am not looking for someone to do the problem for me, however, I have absolutely no idea how to solve this issue.
We are learning "else if" statements (however, my knowledge is they exist, nothing more) and our assignment is to write a code. The problem breaks down as the following (the names have been changed to protect the innocent):
Gus sells cigars. He sells X and Y cigars, either with or without the ring.
X - $1 w/o; $1.50 with ring
Y - $3 w/o; $4.75 with ring
In order for this to work, do I need to write an (else if) formula with 4 lines? I also do not know how to make a formula follow the specific entry at the bottom.
Also, we were never taught how to specify a range of numbers, but I am guessing with the (else if) it would look like this:
if (qty <50)
{
Net money = (X or Y) *1
}
else if (qty <100)
Net money = (X or Y)* 0.95
{
else if (qty <200)
Net money = (X or Y)* 0.9
}
else if (qty >=200)
Net money = (X or Y) * 0.85
{
So do I need to make 16 different else if statements to compute the final output?
I tried defining constants, but we were never even taught how to do that with else if statements. The logic of "Select X or Y", and then it calculates that value into a formula is beyond the material, but it is a question in the assignment
x * four discounts
(x + ring) * four discounts
y * four discounts
(y + ring) * four discounts
I apologize, as my lack of knowledge makes it difficult to ask the questions correctly and intelligently. I will just type out the problem:
(above cigar variables remain)
The program should ask the user what type of cigar they want, then whether it should have a ring or not, and then the total quantity of the purchase. It should then give out the following information:
price = 0
if ( type is X )
if ( with ring )
price =
else
price =
else if ( type is Y )
if ( with ring )
price =
else
price =
total = qty * price
determine discount