This time we will try to program C + + to show the value of letters of numbers entered by the user. So for example user input 85 numbers then it will display the letter A. Problem selengkapkanya are as follows:
By using the IF statement, create a program to display the letter from the value entered by the user, with sebegai following provisions:
• If the value is greater than 80, then the value of letter = A
• If the value is greater than 75, then the value of letter = B
• If a value greater than 65, then the value of letter = C
• If the value is greater than 45, then the value of letter = D
• If the value is less than or equal to 45, then the value of letter = E
• If the input value is greater than 100 or less than 0, it will display the message "wrong input".
To make the program C + + displays the value of letters as a matter of the above, we can use the IF statement. The following source code C + + program to display the value of these letters:
By using the IF statement, create a program to display the letter from the value entered by the user, with sebegai following provisions:
• If the value is greater than 80, then the value of letter = A
• If the value is greater than 75, then the value of letter = B
• If a value greater than 65, then the value of letter = C
• If the value is greater than 45, then the value of letter = D
• If the value is less than or equal to 45, then the value of letter = E
• If the input value is greater than 100 or less than 0, it will display the message "wrong input".
To make the program C + + displays the value of letters as a matter of the above, we can use the IF statement. The following source code C + + program to display the value of these letters:
01 # include <iostream> 02 # include <conio.h> 03 04 void main () 05 { 06 court <<"Program Point Value" <<endl; 07 int bil; 08 court <<"Enter the value number:"; 09 cin>> bil; 10 if (bil> 100 | | bil <0) 11 court <<"Input wrong"; 12 else if (bil> 80) 13 court <<"The value of letter = A"; 14 else if (bil> 75) 15 court <<"The value of letter = B"; 16 else if (bil> 65) 17 court <<"The value of letter = C"; 18 else if (bil> 45) 19 court <<"The value of letter = D"; 20 else 21 court <<"The value of letter = E"; 22 getch (); 23 } |
Explanation of the program displays the value of the letter:
In accordance with the provisions in question, then we must ensure that if the input is above 100 or below 0 will display the message "Input wrong", therefore first tested whether the input above 100 or below 0. Further testing of the new input values to determine the value of the letters according to the provisions on the matter.
Tidak ada komentar:
Posting Komentar