Cari Blog Ini

Kamis, 21 April 2011

Showing Value Letter With IF

Showing Value Letter With IF
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:


# include
# include

void main ()
{
court <<"Program Point Value" <> bil;
if (bil> 100 | | bil <0) court <<"Input wrong"; else if (bil> 80)
court <<"The value of letter = A"; else if (bil> 75)
court <<"The value of letter = B"; else if (bil> 65)
court <<"The value of letter = C"; else if (bil> 45)
court <<"The value of letter = D";
else
court <<"The value of letter = E";
getch ();
}

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