Question

What is my code missing? #include <iostream> #include <string> using namespace std; const double PI =...

What is my code missing?

#include <iostream>
#include <string>
using namespace std;

const double PI = 3.141592;
const int LEGAL_AGE = 21;

int main()
{
   double radius;   // input variable holds radius of circle
   int age;       // input variable holds age of user
   string name;       // input variable holds first name of user

   // prompt user for radius
   cout << "Please enter the radius of your circle: ";
   cin >> radius;

   // compute and display the area and circumference
   cout << "Area of circle of radius " << radius << ": " << ____;
   cout << "\nCircumference of circle of radius " << radius << ": " << ____;

   // prompt user for name and age
   // and input name and age
   cout << "\n Welcome, " << ____ << ", you are " << ____ << " years old";
   cout << "\n\nIf you are " << ____ << " or older, you can buy beer.";
   cout << "\n\nIf you are " << ____ << " or older, you can get married w/o your parents' permission.";
   cout << "\n\nIf you are " << ____ - 3 << ", you can vote.";
   cout << "\n -- Done --" << endl;
   return 0;
}

Homework Answers

Answer #1
#include <iostream>
#include <string>
using namespace std;

const double PI = 3.141592;
const int LEGAL_AGE = 21;

int main()
{
   double radius;   // input variable holds radius of circle
   int age;       // input variable holds age of user
   string name;       // input variable holds first name of user

   // prompt user for radius
   cout << "Please enter the radius of your circle: ";
   cin >> radius;

   // compute and display the area and circumference
   cout << "Area of circle of radius " << radius << ": " << (PI*radius*radius);
   cout << "\nCircumference of circle of radius " << radius << ": " << (2*PI*radius);

   // prompt user for name and age
   // and input name and age
   cout<<"Enter name: ";
   cin>>name;
   
   cout<<"Enter age: ";
   cin>>age;
    
   cout << "\n Welcome, " << name << ", you are " << age << " years old";
   cout << "\n\nIf you are " << 18 << " or older, you can buy beer.";
   cout << "\n\nIf you are " << 18 << " or older, you can get married w/o your parents' permission.";
   cout << "\n\nIf you are " << 21 - 3 << ", you can vote.";
   cout << "\n -- Done --" << endl;
   return 0;
}

Know the answer?
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
Similar Questions
#include<iostream> #include<iomanip> using namespace std; int main() { //variables int choice; float radius,base,height,area; const double PI=3.14159;...
#include<iostream> #include<iomanip> using namespace std; int main() { //variables int choice; float radius,base,height,area; const double PI=3.14159; //repeat until user wants to quits while(true) { //menu cout<<endl<<endl<<"Geometry Calculator"<<endl<<endl; cout<<"1. Calculate the area of a circle"<<endl; cout<<"2. Calculate the area of a triangle"<<endl; cout<<"3. Quit"<<endl<<endl; //prompt for choice cout<<"Enter your choice(1-3): "; cin>>choice; cout<<endl; //if choice is circle if(choice==1) { cout<<"What is the radius of the circle? "; cin>>radius; //calculating area area=PI*radius*radius; cout<<endl<<"The area of the circle is "<<fixed<<setprecision(3)<<area<<endl; } //if choice...
This code it's not working, fix it for me please #include <iostream> using namespace std; class...
This code it's not working, fix it for me please #include <iostream> using namespace std; class People {    string name;    double height; public:    void setName(string name)    {        this->name = name;    }    void setHeight(double height)    {        this->height = height;    }    double getHeight() {        return height;    }    string getName()    {        return name;    } }; int main() {    const int size...
Need someone to fix my code: #include<iostream> using namespace std; struct student { double firstQuizz; double...
Need someone to fix my code: #include<iostream> using namespace std; struct student { double firstQuizz; double secondQuizz; double midTerm; double finalTerm; string name; }; int main() { int n; cout<<"enter the number of students"<<endl; cin>>n; struct student students[n]; int i; struct student istudent; for(i=0;i<n;i++) {    cout<<"Student name?"; cin >> istudent.name; cout<<"enter marks in first quizz , second quizz , mid term , final term of student "<<i+1<<endl; cin>>students[i].firstQuizz>>students[i].secondQuizz>>students[i].midTerm>>students[i].finalTerm; } for(i=0;i<n;i++) { double marks=0; double score=students[i].firstQuizz+students[i].secondQuizz+students[i].midTerm+students[i].finalTerm; marks=(students[i].firstQuizz*0.25)+(students[i].secondQuizz*0.25)+(students[i].midTerm*0.25)+(students[i].finalTerm*0.50); double totalArrgegateMarks =...
C++ #include<iostream> #include<string> #include<fstream> #include<cstdlib> using namespace std; const int ROWS = 8; //for rows in...
C++ #include<iostream> #include<string> #include<fstream> #include<cstdlib> using namespace std; const int ROWS = 8; //for rows in airplane const int COLS = 4; void menu(); //displays options void displaySeats(char[][COLS]); void reserveSeat(char [ROWS][COLS]); int main() { int number=0; //holder variable char seatChar[ROWS][COLS]; for (int i = 0; i < ROWS; i++) { for (int j = 0; j < COLS; j++) { seatChar[i][j] = '-'; } } int choice; //input from menu bool repeat = true; //needed for switch loop while (repeat...
#include <iostream>using namespace std;int main(){ char meal_choice; //user's choice int servings, total_calories; // Display greeting: cout...
#include <iostream>using namespace std;int main(){ char meal_choice; //user's choice int servings, total_calories; // Display greeting: cout << "Welcome to the Calorie Count-ulator!\n"; // Get user input: cout << "Enter your meal choice ([P]izza, [S]alad, [H]amburger)\n"; cin >> meal_choice; cout << "Enter the amount of servings (1-9):\n"; cin >> servings; // TODO: Use a switch statement to evaluate the user's meal choice // Handle error checking where appropriate // Exit the program: return 0;}
There are 7 syntax errors and 3 semantic errors in the following code segment. Please mark...
There are 7 syntax errors and 3 semantic errors in the following code segment. Please mark them in the code and explain the reason briefly in place. #include<iostream> using namespace std; int main() { cout<<”Please input the radius (in integer): ”>>endl; int 1var = 10, var=20; double area = 40; cin<< var; //get an input of the radius and store in var float continue; float const pi = 2.64; pi += 0.5; do { cout<<”The radius is ”<<”var”<<endl; //print the...
Rewrite the following program using switch statements. //Set 7.1 #include <iostream> #include <iomanip> using namespace std;...
Rewrite the following program using switch statements. //Set 7.1 #include <iostream> #include <iomanip> using namespace std; int main() {        int x;        cout << "Selection option " << endl;        cin >> x;        if (x == 1)               cout << "You select option 1" << endl;        else if (x >= 2 || x <= 4)               cout << "You select options 2 or 3 or 4" << endl;               else if (x == 10)               cout << "You select option 10" << endl;               else...
in C++ Need a heap-sort function #include <iostream> #include <stdlib.h> #include <string> using namespace std; void...
in C++ Need a heap-sort function #include <iostream> #include <stdlib.h> #include <string> using namespace std; void MyFunc ( int *array ) { // Your code here ----------------- } int main(int argc,char **argv) { int *Sequence; int arraySize; // Get the size of the sequence cin >> arraySize; // Allocate enough memory to store "arraySize" integers Sequence = new int[arraySize];    // Read in the sequence for ( int i=0; i<arraySize; i++ ) cin >> Sequence[i]; // Run your algorithms to...
Quick sort func in C++ #include <iostream> #include <stdlib.h> #include <string> using namespace std; void MyFunc...
Quick sort func in C++ #include <iostream> #include <stdlib.h> #include <string> using namespace std; void MyFunc ( int *array ) { // Code here } int main(int argc,char **argv) { int *Sequence; int arraySize; // Get the size of the sequence cin >> arraySize; // Allocate enough memory to store "arraySize" integers Sequence = new int[arraySize];    // Read in the sequence for ( int i=0; i<arraySize; i++ ) cin >> Sequence[i]; // Run your algorithms to manipulate the elements...
#include <iostream> #include <string> using namespace std; string STUDENT = "ckim84"; // Add your Blackboard login...
#include <iostream> #include <string> using namespace std; string STUDENT = "ckim84"; // Add your Blackboard login name extern string ASSIGNMENT; /** * Describe the purpose of your program here. * @return 0 for success. */ int run() { repeatChar(3, "abcde$"); return 0; } string repeatChar(int n, const string& pat) { string result; for (int i = 0; i < n; i++) { result += pat; } return result; } could you correct my code?? i got an error msg like...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT