Question
Create a program that will ask for the name, age, address, and favorite food of the user. After which, create a calculator with ADD, SUB, MULTI, and DIV. Then the program will display all the user have inputted in bash program
ACTIVITY 4: Create a program that will ask for the name, age, address, and favorite food of the user. After which create a ca
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi There,

I have implemented the requested program in bash, which will display message based on user input. Please comment below if you need more information.

Output:

Code:

#!/bin/sh

for i in {1..4} # loop for 4 iterations , update the range if you need more iterations
do
read -p "Name: " Name; # read name
read -p "Age: " Age; # read age
read -p "Address: " Address; # read address
read -p "Favorite Food: " Food; # read food
read -p "Enter a Number: " Number1; # read first number
read -p "Enter another Number: " Number2; # read second number
read -p "operator: " Operator; # read the operator
Result=0; # intialize result to 0
if [ "$Operator" = + ]; then # if operator is + add inputs
Result=$((Number1 + Number2))
elif [ "$Operator" = - ]; then # if operator is - subtract inputs
Result=$((Number1 - Number2))
elif [ "$Operator" = / ]; then # if operator is / divide inputs
Result=$((Number1 / Number2))
else # if operator is none of the above then divide inputs.
Result=$((Number1 * Number2))
fi
# print the details.
echo Hello $Name you are aged $Age. You Live Somewhere in $Address. You have input numbers $Number1 and $Number2 with an operator of $Operator. The output is $Result.
echo Thank you for your time using this Bash Program. Bye.
done

Add a comment
Know the answer?
Add Answer to:
Create a program that will ask for the name, age, address, and favorite food of the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a class “Person” which includes first name, last name, age, gender, salary, and haveKids (Boolean)...

    Create a class “Person” which includes first name, last name, age, gender, salary, and haveKids (Boolean) variables. You have to create constructors and properties for the class. Create a “MatchingDemo” class. In the main function, the program reads the number of people in the database from a “PersonInfo.txt” file and creates a dynamic array of the object. It also reads the peoples information from “PersonInfo.txt” file and saves them into the array. In C# Give the user the ability to...

  • In this assignment, you will implement Address and Residence classes. Create a new java project. Part...

    In this assignment, you will implement Address and Residence classes. Create a new java project. Part A Implementation details of Address class: Add and implement a class named Address according to specifications in the UML class diagram. Data fields: street, city, province and zipCode. Constructors: A no-arg constructor that creates a default Address. A constructor that creates an address with the specified street, city, state, and zipCode Getters and setters for all the class fields. toString() to print out all...

  • 7.2 Write a Java program called to create an Excel spreadsheet Create a class called Food...

    7.2 Write a Java program called to create an Excel spreadsheet Create a class called Food to represent a Lunch food item. Fields include name, calories, carbs In a main method (of a different class), ask the user "How many things are you going to eat for lunch?". Loop through each food item and prompt the user to enter the name, calories, and grams of carbs for that food item. Create a Food object with this data, and store each...

  • Write a class named Address that takes four strings that represent the fields of any address...

    Write a class named Address that takes four strings that represent the fields of any address as private member variables. For example: Street = "456 mission street" City = "Hayward" State = "CA" zip code = 94542 To display any address you use the cout << operator in the main function to display any "Address" object created. You should overload the operator to work with the Address class. The class also has another member function named "displayAddress" that prints the...

  • Create a function john, accepts a structure of type employee and return the same structure. Ask...

    Create a function john, accepts a structure of type employee and return the same structure. Ask the user using printf and scanf to enter employee information (name, id and salary). You might use fgets for name, as scanf can not be used for strings with spaces. In main: Declare a structure of type employee Call function john and pass the structure. Display using prinf employee structure information returned from function john.

  • Simple calculator program. The program should ask the user for a number, an operator, and then...

    Simple calculator program. The program should ask the user for a number, an operator, and then a second number. The operator should be either '+', '-', 'x', or '/'. The program should then report the answer to the problem. Use a switch statement, not an if statement. Note that "operator" is a reserved word in C++, so you cannot use it as a variable name. Use double variables and setprecision(2).

  • Using C++ create a class called person. A person can have a name, address, age. For...

    Using C++ create a class called person. A person can have a name, address, age. For this class create a default constructor and parameterized constructor. Show the main as int main() { } ----------------------------------------------------- Show how you will define the class and call it in the main. Only create two instances/objects in main using the two created constructors.

  • You will create flowchart using Flowgorithm and Pseudocode for the following program example:&nbs...

    you will create flowchart using Flowgorithm and Pseudocode for the following program example:   Pet Care is a doggy day care that would like you to create a program that accepts the dog owner's name pet's name, breed, age and weight of the dog. The program should allow the user to enter this data until a sentinel value is reached. Then it will display the dog's name if the dog weighs less than 20 pounds or more than 100 pounds (be...

  • Create a class in Java with instance variables to hold the name, street address, city, and...

    Create a class in Java with instance variables to hold the name, street address, city, and state for a user. These instance variables should be private. You should enter the name and address in the nameAddress method. You should enter the city and state in the cityState method. In the main method, print the complete address using the method printAddress. You should not use the static keyword except for the main method. Your output should be similar to the output...

  • [PYTHON] Create a chatbot program in Python: a program that appears to talk intelligently to a...

    [PYTHON] Create a chatbot program in Python: a program that appears to talk intelligently to a human using text. Your program should involve asking the user questions and having the computer respond in a reasonably intelligent fashion based on those answers. For example, here is a sample chat: ChatBot: Welcome, I am Chatbot . What is your name? User: My name is Abby . ChatBot: Hello Abby. How old are you? User: 22. <---- Input ChatBot: That is older than...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT