Answer:
Hope this works
#include <iostream>
#include <string>
#include <vector>
using namespace std;
string digitName(int digit);
string teenName(int number);
string tensName(int number);
string intName(int number);
vector<string> ones {"","one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
vector<string> teens {"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen","sixteen", "seventeen", "eighteen", "nineteen"};
vector<string> tens {"", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"};
string nameForNumber (long number) {
if (number < 10) {
return ones[number];
} else if (number < 20) {
return teens [number - 10];
} else if (number < 100) {
return tens[number / 10] + ((number % 10 != 0) ? " " + nameForNumber(number % 10) : "");
} else if (number < 1000) {
return nameForNumber(number / 100) + " hundred" + ((number % 100 != 0) ? " " + nameForNumber(number % 100) : "");
} else if (number < 1000000) {
return nameForNumber(number / 1000) + " thousand" + ((number % 1000 != 0) ? " " + nameForNumber(number % 1000) : "");
} else if (number < 1000000000) {
return nameForNumber(number / 1000000) + " million" + ((number % 1000000 != 0) ? " " + nameForNumber(number % 1000000) : "");
} else if (number < 999000000001) {
return nameForNumber(number / 1000000000) + " billion" + ((number % 1000000000 != 0) ? " " + nameForNumber(number % 1000000000) : "");
}
return "error";
}
int main()
{
long input;
do
{
cout << "Please enter a positive integer: ";
cin >> input;
cout << "\n" << nameForNumber(input) << endl;
cout << "\n\n" << endl;
}while (input > 0);
return 0;
}
Using the chores.csv file fat the very bottom; write an awk script to return the average number of minutes required to complete a chore. Your solution must handle an undefined number of chores. zero points will be given to solutions that use a static number in their calculation.
Format floating point numbers to 2 decimal places.
Example output;
Average: 28.12
chores.csv
Chore Name,Assigned to,estimate,done?
Laundry,Chelsey,45,N
Wash Windows,Sam,60,Y
Mop kitchen,Sam,20,N
Clean cookware,Chelsey,30,N
Unload dishwasher,Chelsey,10,N
Dust living room,Chelsey,20,N
Wash the dog,Sam,40,N
Answer: Provided in the explanation section
Explanation:
According to the question:
Using the chores.csv file fat the very bottom; write an awk script to return the average number of minutes required to complete a chore. Your solution must handle an undefined number of chores. zero points will be given to solutions that use a static number in their calculation.
Format floating point numbers to 2 decimal places.
Example output;
Average: 28.12
chores.csv
Chore Name,Assigned to,estimate,done?
Laundry,Chelsey,45,N
Wash Windows,Sam,60,Y
Mop kitchen,Sam,20,N
Clean cookware,Chelsey,30,N
Unload dishwasher,Chelsey,10,N
Dust living room,Chelsey,20,N
Wash the dog,Sam,40,N
ANSWER:
BEGIN{
FS=","
}
{
if(NR!=1)
sum += $3
}
END{
avg=sum/NR
printf("Average: %.2f ", avg)
}' ./chores.csv
cheers i hope this helped !!
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