.. (לתיקייה המכילה) | ||
in Q1, may I assume that the length is appropriate? | |
Length may be either positive, 0 or negative (which results means the driver is driving backwards). All these lengths are OK. |
in Q2, may I assume anything about the number of digits in the number? | |
no, you may just assume that an int variable will store the number correctly. |
In Q3, may I use double for the input number? | |
yes, but it is not recomended. Generalization of the problem for real numbers will most likely complicate the problem. |
in Q4, what should be the result of the mutlplication presented to the user when 0 is among the numbers that were entered? | |
0. |
In Q4, what should be the result before any number was eneterd? | |
1. |
can i use somethings that havn't been learned in class. | |
yes, you can. but make sure you're doing it right. |
In Q2, If the user enters number that ends with 0, should the program return leading 0? | |
yes, the program should return leading 0. for example, 10 should turn to 01. |
The code in the following if statement is executed even when x does not equal to 5. Why is that? | |
The = is an assignment operator. This means that the code inside the if condition actually assigns x to be 5 and causes the condition to be true which will make the program print "Hello" (we will learn more about this later in the course). if you want to compare two numbers you have to use the == operator, like this: if (x == 5) : In this case the value of x is not changed, and the code in the curly braces will be executed only when x equals to 5. |
In Q2, what shall i do if i get a number with leading zeros? should i ignore them? | |
yes, you should ignore them. (you read the number as an integer so you cannot know if the user wrote leading zeros) |
What should the output be, if Departure time = Arrival time? | |
you need to check that the Arrival time is later than the if the Departure time, so if "Departure time" = "Arrival time" than it's not later than and the output should be "error: arrival time is earlier than departure time" |
What should the output be if The inputted velocity is 0? | |
Even that velocity 0 is no realy a reverse we didn't want to add another thing to check, so you can treat it like reverse |
if no numbers were entered, it should be presented to the user that the current multiplication is 1. | |
mul should be initialize to be 1 |