Write a program that determines the bigger of the two numbers provided by the user. At first, the program asks the user to enter a number. Then it asks the user to enter another but different number. Following that, it determines the bigger of the two numbers and displays it to the user. Implementation Do this assignment by using an if/else statement. Testing Use Input/Output dialog shown in test run 1 and test run 2. (User input is shown in bold). Test Run 1 Enter the First Number 12 Enter a Different Second Number 15 First number: 12 Second number: 15 Larger number: 15 Test Run 2 Enter the First Number 15 Enter a Different Second Number 12 First number: 15 Second number: 12 Larger number: 15 Discussion Of the If/Else Statement Full Syntax The syntax of the if/else statement is given below: if (expression) { //Enter here one or more statements. } else { //Enter here one or more statements. } The word if and else are reserved words and must be used in the if/else statement. Following the reserved word if, specify an expression within parentheses. Following the parenthesized expression is an open brace and a close brace as shown above. You can put any number of statements within those braces. The word else is a reserved word and must be used in the if/else statement as above. In the else part of the if/else statement, following the word else is an open brace and a close brace as shown above. You can put any number of statements within those braces. In the if/else statement, when the value of the expression is true, then the statements within braces in the if part are executed. Otherwise, the statements within the braces in the else part are executed. Always, either the statements in the if part or the statements in the else part are executed. Never the statements in both the parts are executed. Also never the statements in both the parts are ever skipped. On completing the if/else statement, the program continues to the statement following the if/else statement. Short Syntax. In the if/else statement, in the if or the else part, when there is only a single statement within a pair of braces, then that pair of braces can be skipped. However, if any of the pair of braces contain multiple statements, then that pair of braces cannot be skipped. |
|
|
acount=0, bcount=0, count=0, dcount=0, and fcount=0.
fcount=0-59, dcount=60-69
, and so forth? if(score>-90.0) acount=acount+1
|
|