Write the program convertChar that will read in one character (type, char) and then
if the input is uppercase, print the lowercase letterif the input is lowercase, print the uppercase letter
if the input is anything else, just print the character
When testing a character, use the character value, not the ASCII (numeric code) value. For example, use 'a' rather than 97.
Also, do not write an if-statement for every possible character. Rather, use a range check to determine whether the char variable's value is within a particular range. For example, if the char variable (input) is between 'a' and 'z', inclusive, then the input was lower case. Your code must have no more than TWO if-statements.
Be sure to prompt the user for input and label all results.
Your programs execution should produce output like the following examples (user input in bold blue):
Example 1:
Enter a character: h
The uppercase of 'h' is 'H'.
Example 2:
Enter a character: B
The lowercase of 'B' is 'b'.
Example 3:
Enter a character: ]
You enter non-letter, ']'.
NOTE: The examples above are EXAMPLES! Your code should work for any character that the user might enter.
Here is my attempt
#include <iostream>// Includes here (NOTE: No semicolons in #includes)
using namespace std;
int main ()// main program that executes code.
{
cout << "Enter a character: ";
char c;
cin >> c;
cout << "The uppercase of character is: " << c << endl;
Write the program calculate that will read in two double values and then an integer. If the integer is 1, then print the sum of the doubles; if the integer is 2, then print the product of the doubles; if the integer is 3, print the doubles in ascending (increasing) order; if the integer is any other value, print an error message.
You must use a switch statement to test the integer input. You can assume that the first two inputs are double and that the third input is an integer. Be sure to prompt the user for input and label all displayed results.
Be sure not to do any of the three possible calculations unless and until the corresponding integer value is entered. In other words, only add the values if the integer is 1, only multiply if the integer is 2 and only sort them if the integer is 3.
Store your program in the file calculate.cpp. Be sure to check your answers.
Here is my attempt
#include <iostream>// Includes here (NOTE: No semicolons in #includes)
using namespace std;
int main ()// main program that executes code.
{
int n1, n2, n3
switch (op){
case 1:
(n1 + n2)
break;
case 2:
(n1 * n2)
break;
case 3:
if (n1 < n2)
cout << n1 << << n2;
else cout << n2
break;
default:
cout << 'error'.
}