Question

Write a SIMPLE code in c++ to input a user's age, name, date, month and year...

Write a SIMPLE code in c++ to input a user's age, name, date, month and year of birth, favorite color and so on. You will then turn around and ask another person the same and do this for 9 people. You will then output these information for these 9 people back to the screen in the same order. Further, add the ages of all these people and output the total to the screen. comment the code

0 0
Add a comment Improve this question Transcribed image text
Answer #1

******************************************************************************************
Please Upvote the answer as it matters to me a lot :)
*****************************************************************************************
As HOMEWORKLIB RULES expert answering guidelines,Experts are supposed to answer only certain number of questions/sub-parts in a post.Please raise the remaining as a new question as HOMEWORKLIB RULES guidelines.
******************************************************************************************

#include <bits/stdc++.h>
using namespace std;
int main()
{
string s[9][5];
int age[9];
for(int i=0;i<9;i++)
{
cout<<"Enter user age: ";
cin>>age[i];
cout<<"Enter name";
cin>>s[i][0];
cout<<"Enter date";
cin>>s[i][1];
cout<<"Enter month";
cin>>s[i][2];
cout<<"Enter year of birth";
cin>>s[i][3];
cout<<"Enter favorite color";
cin>>s[i][4];
}
int ans=0;
for(int i:age)
ans+=i;
  
for(int i=0;i<9;i++)
{
cout<<" Age: ";
cout<<age[i]<<" ";
cout<<"Name: ";
cout<<s[i][0]<<" ";
cout<<"Date: ";
cout<<s[i][1]<<" ";
cout<<"Month: ";
cout<<s[i][2]<<" ";
cout<<"Year of birth: ";
cout<<s[i][3]<<" ";
cout<<"Favorite color";
cout<<s[i][4]<<endl;
}
cout<<"Total age is "<<ans<<endl;
  
return 0;
}

Add a comment
Know the answer?
Add Answer to:
Write a SIMPLE code in c++ to input a user's age, name, date, month and year...
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 program that will ask for the name, age, address, and favorite food of the...

    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 calculator with ADD, SUB, MULTI, and DIV. Then the program will display all the user have...

  • c. print python code that requests a person's first name, birth year, birth month like 'January',...

    c. print python code that requests a person's first name, birth year, birth month like 'January', and birth day of month as input, then outputs a full sentence using the three inputs and another sentence that tells the length of the previous sentence that was printed.. Include one line of comment explaining each line of code: d., print python code that assigns the 4 variables shown in step 8 the math formulas created in step 8. Output a sentence that...

  • I need help creating a code in assembly, requesting at least 2 user inputs and printing it on the screen. ( on Ubuntu) What is your name?sam Hello sam What is your age?19 WOW! YOUR'E, 19 What is...

    I need help creating a code in assembly, requesting at least 2 user inputs and printing it on the screen. ( on Ubuntu) What is your name?sam Hello sam What is your age?19 WOW! YOUR'E, 19 What is your birth month august No way! I was born in august What is your favorite color?red Mine is also red What is your name?sam Hello sam What is your age?19 WOW! YOUR'E, 19 What is your birth month august No way! I...

  • print python code that requests a person's first name, birth year, birth month like 'January', and...

    print python code that requests a person's first name, birth year, birth month like 'January', and birth day of month as input, then outputs a full sentence using the three inputs and another sentence that tells the length of the previous sentence that was printed.. Include one line of comment explaining each line of code

  • Python assignment:  Write a program that asks for the user's age. Based on their response print "You...

    Python assignment:  Write a program that asks for the user's age. Based on their response print "You can vote" (18 years old or older) or "You can't vote" and also whether or not he/she is a senior citizen (over 64). If senior citizen print "You're a Senior Citizen...you deserve two votes"!   Use the Idle editor and don't forget the .py extension. Good luck.          Your python program will be graded on the following:     Execution of the program gives the correct...

  • Write a C++ code to make a simple program that imports the input file in and...

    Write a C++ code to make a simple program that imports the input file in and gets the results as specified Please follow the instructions and paste the code below as the answer with a screenshot of the output to prove it worked. Input file -> https://www.dropbox.com/s/444jofkchu6ylwr/names.txt?dl=0 Scoring Names You will be using the provided names.txt file, text file containing over five-thousand first names, and you will calculate a score for each name. Begin by reading the names from the...

  • Please write this code in C++ Object-Oriented Programming, specify which files are .h, and .cpp, and...

    Please write this code in C++ Object-Oriented Programming, specify which files are .h, and .cpp, and please add comments for the whole code. Include a class diagrams, and explain the approach you used for the project and how you implemented that, briefly in a few sentences. Please note the following: -Names chosen for classes, functions, and variables should effectively convey the purpose and meaning of the named entity. - Code duplication should be avoided by factoring out common code into...

  • C++ There is a class called Person which has name and age as private variables. Another...

    C++ There is a class called Person which has name and age as private variables. Another class called Student, which is derived from person with gpa and id as variables. name is a string, age and id are integers and gpa is a double... All of them are private variables. age, gpa and id should be generated randomly when the object is created with the following ranges: age 20 to 32 gpa 0.0 to 4.0 // this one is tricky...

  • python code? 1. Create a class called Person that has 4 attributes, the name, the age,...

    python code? 1. Create a class called Person that has 4 attributes, the name, the age, the weight and the height [5 points] 2. Write 3 methods for this class with the following specifications. a. A constructor for the class which initializes the attributes [2.5 points] b. Displays information about the Person (attributes) [2.5 points] c. Takes a parameter Xage and returns true if the age of the person is older than Xage, false otherwise [5 points] 3. Create another...

  • Java Object Array With 2 Elements In 1 Object

    1. Create a UML diagram to help design the class described in Q2 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Person class object; should they be private or public? Determine what class methods are required; should they be private or public?2. Write Java code for a Person class. A Person has a name of type String and an age of type integer.Supply two constructors: one will be...

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