Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I have been working on this code but I keep running into problem. Please help me review and run it, too. Text Book: Starting

Hello,

I have been working on this code but I keep running into problem. Please help me review and run it, too.

Text Book: Starting Without C++.

  • To work with cout and cin objects
  • To work with variables, constants and literals
  • To work with string object
  • Use of different data types
  • To follow programming style
  • Use of basic arithmetic operators
  • Use of output manipulators (setw, fixed, setprecision)

Project Description

The Department plans to purchase a humanoid robot. The Chairman would like you to write a program to show a greeting script the robot can use later. Your first task is to use the following script to prototype the robot for presentation:

**************** Robot Prototype Scripting ********************

Hello, welcome to Montgomery College! My name is Nao. May I have your name?

john Smith

Nice to have you with us today, john Smith!

Let me impress you with a small game.

Give me the age of an important person or a pet to you.

Please give me only a number:

2

You have entered 2.

If this is for a person, the age can be expressed as:

2 years

or 24 months

or about 720 days

or about 17280 hours

or about 1036800 minutes

or about 62208000 seconds.

If this is for a dog, it is 14 years old in human age.

If this is for a gold fish, it is 10 years old in human age.

Let's play another game, john Smith. Give me a whole number.

4

Very well. Give me another whole number.

5

Using the operator '+' in C++, the result of 4 + 5 is 9.

Using the operator '/', the result of 4 / 5 is 0

however, the result of 4.0 / 5.0 is about 0.8.

Thank you for testing my program!!

PROGRAMMER: Tina Lee

CMSC140 Common Project 1

Due Date: 2/10/2019

Write a program that uses the script above as a guide without roles, i.e. robot computer and visitor human, to prototype robot greeting in C++. See the Sample Screen Output below.

Project Specifications

Input

  • Visitors name
  • An age
  • Two numbers

Output: The program should display the following data:

  • Complete script described above
  • Your name as the programmer
  • Assignment/Project number
  • Due date

Processing Requirements

  1. The program should declare and initialize (i.e. create and assign values for) variables/constants to hold (at least) the following data:
  • Robot Name. This variable will hold the Robot Name. Initialize the variable with Nao or a name of your choice.
  • Visitor Name, this variable will hold the users name.
  • Age. This variable will hold a persons or a pets age.
  • A constant variable for Programmers Name. Initialize the variable with your full name.
  • A constant variable for Assignment Number. Initialize the variable with the value 1.
  • A constant variable for Due Date. Initialize the variable with the due date of this assignment.
  • Constant variables for Days of Month, Human Year, Gold Fish Year. Initialize the variables, for example const int ONE_DOG_YEAR = 7; const int DAYS_PER_MONTH = 30;
  1. Use the above variables when creating the output of the program, for example:

cout << My name is << robotName;

Where robotName is a variable defined in your program.

  1. Use the following for the computations in the program :

  • 1 month = 30 days
  • Dogs age = 7 times humans age,
  • Gold fish age = 5 times humans age

Student Note: Please see my code below: It keeps showing error. Please give me a breakdown of what caused the program not to compile.

# include # include using namespace std; int main() {

string robot_name = " Jenneh"; string visitor_name; int age, number_one, number_two string programmer_name = " Jusu Dukuly"; string homework_number = "1"; //constant variable for due date const string due_date = "February 8, 2020"; // Write the robot name in the script cout << "Hello, Welcome to Montgomery college"; cout << "My name is" << robot_name << ". May I have your name?" << " "; // Take visitor name as input cin >> visitor_name; // Write the vistor name as a script cout << " It is good to have you with us today," << visitor_name << "!"; cout << " Let me entertain you a bit with small game."; cout << " Give me the age of a person or pet to you."; cout << " Please give me only a number"; //Take human age as input from visitor cin >> age; //Write human age as scrupt cout << " You have entered" << age << ". Only if this is for a person,"; cout << "the age can be read as " << age << "year or"; //Compute the months, days, hours, minutes and second from the age input. double months = age * 12; double days = months * 30; double hours = days * 24; double minutes = hours * 60; double secounds = minutes * 60; //Compute dog and fish age double dog_age = 7 * age; double gold_fish = 5 * age; //Display the months, hours, minutes, and seconds as a script cout << months << " months or about" << days << " days or"; cout << " about" << fixed << setprecission(0) << hours << "hours or about" << minutes; cout << " Or about" << fixed << setprecision(0) << seconds << "seconds. If this is for a dog, "; //Display dog age and gold fish age as script cout << "it is" << dogs_age << "years old in human age."; cout << " If this is for a gold fish, it is " << gold_fish_age; cout << " years old in human age" << " "; cout << "Let play another game" << visitor_name <<"!"; cout << "Give me a whole number." << " "; //Take first whole number from the visitor cin >> number_one; cout << " very well. Give me one more whole number "; //Take second whole number from the visitor cin >> number_two; //compute sum and division that display in the script double sum = number_one+number_two; double division = number_one/number_two; float division = (float)number_one/number_two; //Display sum and division script cout << " Using the operator '+'C++,"; cout << "the result of" << number_one << "+" << number_two; cout << "is" << sum << ". Using the operator '/', the answer"; cout "of" << number_one << "/" << number_two << "is" <<"."<<" "; cout << "; however, the result of" << number_one << "/" << number_two; cout << " is about" << floatDivision << visitor_name << "?"; //Display programmer Name, Assignment Number and due date to output screen cout << "Thank you for testing my program: programmer Name: " << Programmer_name << endl; cout << "Assignment Number:" << assignment_number << endl; cout << "Due Date:" << due_date << endl; return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions

Question

Which are non projected Teaching aids in advance learning system?

Answered: 1 week ago