Question

In: Computer Science

1. Write a program that will ask the user to enter a character and then classify...


1. Write a program that will ask the user to enter a character and then classify the character as one of the following using only IF-ELSE and logical operators. (50 points - 10pts for syntax, 10pts for commenting and 30pts for successful execution)
• Integer
• Lower Case Vowel
• Upper Case Vowel
• Lower Case Consonant • Upper Case Consonant • Special Character

Solutions

Expert Solution

#include <iostream>
using namespace std;

int main()
{
char ch;
cout<<"Enter Any Character:";
cin>>ch;
if(ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U') //Check for enter character is "Upper Case Vowel"
{
cout<<"Upper Case Vowel";
}
else if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')//Check for enter character is "Lower Case Vowel"
{
cout<<"Lower Case Vowel";
}
else if(ch == '!' || ch == '@' || ch == '#' || ch == '$' || ch == '%' || ch == '^' || ch == '&' || ch == ' ' || ch == '(' || ch == ')' || ch == '*' || ch == '"' || ch == '+' || ch == ',' || ch == '-' || ch == '.' || ch == '/' || ch == ':' || ch == ';' || ch == '<' || ch == '=' || ch == '>' || ch == '?'|| ch == '['|| ch == ']'|| ch == '~' || ch == '|'|| ch == '}'|| ch == '{'|| ch == '`'|| ch == '_')//Check for enter character is "Special Character"
{
cout<<"Special Character";
}
else if(ch == 'b' || ch == 'c' || ch == 'd' || ch == 'f' || ch == 'g' || ch == 'h' || ch == 'j' || ch == 'k' || ch == 'l' || ch == 'm' || ch == 'n' || ch == 'p' || ch == 'q' || ch == 'r' || ch == 's' || ch == 't' || ch == 'v' || ch == 'w' || ch == 'x' || ch == 'y' || ch == 'z' )//Check for enter character is "Lower Case Constant"
{
cout<<"Lower Case Constant";
}
else if(ch == 'B' || ch == 'C' || ch == 'D' || ch == 'F' || ch == 'G' || ch == 'H' || ch == 'J' || ch == 'K' || ch == 'L' || ch == 'M' || ch == 'N' || ch == 'P' || ch == 'Q' || ch == 'R' || ch == 'S' || ch == 'T' || ch == 'V' || ch == 'W' || ch == 'X' || ch == 'Y' || ch == 'Z' )//Check for enter character is "Upper Case Constant"
{
cout<<"Upper Case Constant";
}
else if(ch == '0' || ch == '1' || ch == '2' || ch == '3' || ch == '4' || ch == '5' || ch == '6' || ch == '7' || ch == '8' || ch == '9' )//Check for enter character is "Integer"
{
cout<<"Integer";
}
else //when enter character is non of the above
{
cout<<"Your enter character is not integer, character and Special character";
}
return 0;
}


Related Solutions

// This program ask the user to enter a character. It then performs a // linear...
// This program ask the user to enter a character. It then performs a // linear search on a character array and display the number of times // that the character appears on the array. If the character is not in the // array, then it will display a message saying that is was not found. // Add the necessary code for the program to work. // NOTE: // You don't have to edit anything in the main(), just in...
Write a program that will ask the user to enter the amount of a purchase. The...
Write a program that will ask the user to enter the amount of a purchase. The program should then compute the state and county sales tax. Assume the state sales tax is 5 percent and the county sales tax is 2.5 percent. The program should display the amount of the purchase, the state sales tax, the county sales tax, the total sales tax, and the total of the sale (which is the sum of the amount of purchase plus the...
Write a program that allows the user to enter two integers and a character If the...
Write a program that allows the user to enter two integers and a character If the character is A, add the two integers If it is S, subtract the second integer from the first else multiply the integers Display the results of the arithmetic
In java, write a program that asks the user to enter a character. Then pass the...
In java, write a program that asks the user to enter a character. Then pass the character to the following methods. isVowel() – returns true if the character is a vowel isConsonant() – returns true if the character is a consonant changeCase() – if the character is lower case then change it to upper case and if the character is in upper case then change it to lower case. (return type: char) Example output is given below: Enter a character...
Write a program that does the following. It will ask the user to enter an integer...
Write a program that does the following. It will ask the user to enter an integer larger than 1, and the if entered integer is not larger than 1, it keeps prompting the user. After the user enters a valid integer, the program prints all the prime factors of the integer (including the repeated factors). For example, if the entered integer is 24, the program prints: 2 2 2 3 Run your program with the test cases where the entered...
Write a program that does the following in order: 1. Ask user to enter a name...
Write a program that does the following in order: 1. Ask user to enter a name 2. Ask the user to enter five numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5” 3. Calculate the sum of the numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5” 4. If the sum is greater than 0, print out the sum 5. If the sum is equal to zero, print out “Your account balance is zero” 6. If the sum is less than 0, print out “Your account...
Using Python write a program that does the following in order: 1. Ask user to enter...
Using Python write a program that does the following in order: 1. Ask user to enter a name 2. Ask the user to enter five numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5” 3. Calculate the sum of the numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5” 4. If the sum is greater than 0, print out the sum 5. If the sum is equal to zero, print out “Your account balance is zero” 6. If the sum is less than 0, print out...
1. Write a Python program to: ask the user to enter two integers: int1 and int2....
1. Write a Python program to: ask the user to enter two integers: int1 and int2. The program uses the exponential operator to calculate and then print the result when int1 is raised to the int2 power. You also want to calculate the result when int1 is raised to the .5 power; however, you realize that it is not possible to take the square root of a negative number. If the value for int1 that is entered is a negative...
write a program i java that ask the user to enter salary, user ID and username...
write a program i java that ask the user to enter salary, user ID and username and out put them
Write a MIPS program that will ask the user to enter two numbers at the console...
Write a MIPS program that will ask the user to enter two numbers at the console and pass the values to a function that does multiplication
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT