1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Masteriza [31]
3 years ago
6

Design and implement a program (name it Youth) that reads from the user an integer values repressing age (say, age). The program

prints out the entered values followed by a message as follows: If age is less or equal to 21, the message is "Age is a state of mind.". Finally, the program always prints out the message "Age is a state of mind." Format the outputs following the sample runs below.
Sample run 1:
You entered: 20
Youth is a wonderful thing. Enjoy.
Age is a state of mind.
Computers and Technology
1 answer:
slavikrds [6]3 years ago
8 0

Answer:

The programming language is not stated; I'll answer this question using C++ programming language;

Another thing to note is that; the sample run is quite different from the illustration in the question; So, I'll assume the program to print "Youth is a wonderful thing. Enjoy.", if and only if age is less than or equal to 21

The program is as follows

#include<iostream>

using namespace std;

int main()  {

int age;

int i =1;

start:

cout<<"Sample run: "<<i<<endl;

cout<<"You entered: ";

cin>>age;

if(age<=21)  {

 cout<<"Youth is a wonderful thing. Enjoy."<<endl; }

cout<<"Age is a state of mind"<<endl;

i++;

cout<<"Run another? (Y/N): ";

char resp;

cin>>resp;

if(resp=='Y')

{

 goto start;

}

return 0;

}

Explanation:

Line 4 of the program declares age as integer

Line 5 declares and initializes a counter variable, i to 1

Line 6 is used as a label to start another sample run

Line 7 prints the Sample run in the following format;

        Sample run 1, during the first iteration

        Sample run 2, during the second iteration; and so on...

Line 8 prompts the user to supply details for age

Line 9 stores user input in variable age

Line 10 checks if age is less than or equal to 21

If true, the program outputs Youth is a wonderful thing. Enjoy., then it continues execution on line 23

Otherwise, it jumps directly to line 23 and outputs Age is a state of mind

The counter is increased by 1 on line 24

The program asks if the user wants to take another sample run on line 25

The response is saved in a char variable on line 27

If the user response is Y, the program goes to the label on line 6 to begin another iteration

Otherwise, the program is terminated.

See attachment for source file

Download cpp
You might be interested in
Write a program to find a peak in an array of ints. Suppose the array is {-1, 0, 2, 5, 6, 8, 7}. The output should be "A peak is
Sergeeva-Olga [200]

Answer:

Following are the code to this question:

#include<iostream>//declaring header file  

using namespace std;

int main()//main method

{

int n= 6,j=0;//declaring integer variable

int X[n];//defining an array

for(j=0;j<=n;j++)//defining a loop for input value

cin>>X[j];//input value from the user

if(j==0) //defining if block that checks value at beginning

{

if(X[j]>=X[j+1])//defining if block to check to compare first and second value  

{

cout<<"A peak is at array index "<<j<<" and the value is "<<X[j];//use print method to largest value with index number  

}

}

else//defining else block

{

for(j=0;j<=n;j++)//defining for loop for compare other value

{

if(j==n-1) //use if block that checks next index  

{

if(X[j]>=X[j-1])//use if block to compare value  

cout<<"A peak is at array index "<<j<<" and the value is "<<X[j];//use print method to largest value with index number

}

else

{

if(X[j]>=X[j-1] && X[j]>=X[j+1])//comapre value

cout<<"A peak is at array index "<<j<<" and the value is "<<X[j];//use print method to largest value with index number

}

}

}

return 0;

}

Output:

please find the attached file.

Explanation:

In the given code, inside the main method two integer variable "n and j", is declared, in the next step, an array "x"is defined which input the value from the user end.

  • In the next step, multiple if block is used, in the first if block it comapre the first and second value if it grater then it will print the value with its index number.
  • In the next if block, it comapre is next value and if it grater then it will print the value with its index number.  

5 0
3 years ago
HI PLZ HELP 11 POINTS!!!
bonufazy [111]

Probably gonna wanna determine the table title first

6 0
3 years ago
Read 2 more answers
What do you understand by Multiprotocol Label Switching, how it works and is helpful in today's network scenario.
Minchanka [31]

Answer:

Multiprotocol Label Switching (MPLS): It is a routing technique in telecommunications networks that transfers data from 1 node to next node based upon shortest paths instead of long network addresses, hence it avoids rigorous findings in a routing table and speeds the flow of traffic

MPLS provides better performance,scalability,better bandwidth utilization,a better end-user experience and reduced network congestion.Hence it is useful in today's network scenario.

7 0
3 years ago
Which of the following software costs money?
loris [4]
Word 2013. Google docs is free on the web. OpenOffice Writer is a free version on word. Word Online is a free version of word on the web. And Word 2013 cost $200 dollars for just word :-). Oh yeah, the whole office suit is around $300!
7 0
4 years ago
Read 2 more answers
What are the chief contributions of philosophy to artificial intelligence?
olga nikolaevna [1]

Answer

Hi,

The chief contribution of philosophy to artificial intelligence is the knowledge of the connections between the two and the understanding of the shared concept.

Explanation

Philosophy and Artificial intelligence has a close scientific connection because they both share concepts such as action, consciousness, epistemology and free will. From the artificial intelligence perspective, theories in philosophy are important in AI as long as they provide the basis of the designs, reasons and plan. The concepts shared in AI con tribute to the realization of the philosophy of artificial intelligence.

Hope this Helps!

5 0
3 years ago
Other questions:
  • Complete each statement by choosing the correct answer from the drop-down menu.
    10·1 answer
  • When troubleshooting firewalls, which of the following is not something you should do after you attempt a fix?
    7·1 answer
  • What type of scientists studies tree rings to determine the history of an area?
    9·2 answers
  • gAssume that you are writing a program to merge two files named FallStudents and SpringStudents. Each file contains a list of st
    15·1 answer
  • Employers will check you out on social media sites like Facebook, MySpace, and Twitter.
    6·2 answers
  • Which of the following is an object-oriented prototype-based language? Java Pike REBOL MATLAB
    9·1 answer
  • What is the value stored at x, given the statements:
    11·1 answer
  • Data source contains addresses of the merge fields. true or false​
    8·1 answer
  • Determine what is printed by the following code.
    8·1 answer
  • Who is this wrong answers only
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!