Operator Problems
In the problems that ask for evaluation of an expression, if results are floating point, write out result to 2 decimal places
Problem 1:
what does the above expression evaluate to?
what is the final value of x?
what is the final value of y?
Problem 2:
what does the above expression evaluate to?
what is the final value of x?
what is the final value of y?
Problem 3:
A recipe for sweet and sour ribs makes the sauce out of 4 ingredients in different proportions. The recipe uses: 1 part soy sauce, 2 parts vinegar, 3 parts sugar and 4 parts water. Thus, if someone uses 100ml of soy sauce, they would need 200 ml of vinegar, 300ml of sugar and 400ml of water to make up the recipe.
Part A
Write a program that will ask the user for the amount of soy sauce they are using for the recipe and print out the amount of each of the other 3 ingredients.
Sample Run:
Part B
Write a program that will ask the user for the total amount of sauce they want. The program will then figure out how much of each ingredient is needed to the nearest ml and show that to the user.
Sample Run:
Problem 4:
The following is a program that should print out the numbers 1 to 5 one per line:
However, there are bugs in the program (both syntactic and logical).
What is the syntax error generated when you compile the program as is?
Explain what the cause of the syntax error(s) and how to fix it.
What logical error exist in above program?
How do you fix it?
Last updated