Answer:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double num1, num2, num3, num4, num5, sum = 0;
cout << "Input: ";
cin >> num1 >> num2 >> num3 >> num4 >> num5;
sum = num1 + num2 + num3 + num4 + num5;
cout << "Output: " << static_cast<int>(round(sum)) << endl;
return 0;
}
Explanation:
Include cmath to use the round function
Declare the variables
Get the five numbers from the user
Sum them and assign the result to the sum
Round the sum using the round function, and convert the sum to an integer using static_cast statement
Print the sum
Write a script called checkLetter.sh Review Greeting.sh for an example. Use a read statement and ask user to "Enter A, B, or C: "
If user types A, echo "You entered A"
If user types B, echo " You entered B"
If user types C, echo " You entered C"
Use the case structure to test the user’s string.
If user types any letter from lower case ‘a through z’ or upper case ‘D through Z’, echo "You did not enter A, B, or C".
Answer:
The code is given as below: The input and output is as given for one case.
Explanation:
echo -e "Enter A, B or C : \c" #Printing the line on the screen
read -rN 1 test #read the character in the variable test
echo
case $test in #Setting up the case structure for variable test
[[:lower:]] ) #checking all lower case letters
echo You did not enter A, B or C;;
[D-Z] ) #checking upper case letters from D to Z
echo You did not enter A, B or C;;
A ) #Condition to check A
echo You entered A;;
B ) #Condition to check B
echo You entered B;;
C ) #Condition to check C
echo You entered C;;
esac #Exiting the case structure