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
In Microsoft Excel, you have a large dataset that will print on several pages. You want to ensure that related records print on
spin [16.1K]

Answer:

The answer is "Option D".

Explanation:

In Microsoft Excel, A dataset is a collection of the data. In other words a dataset is set of data like, Excel workbooks, spreadsheet tables, or table lists that are configurable objects storing the data. To print data sets related records on the same page we change the print at this data set only print the visible data, it will not print the confidential data. and other options are not correct that can be defined as follows:

  • In option A, It is not correct, because the set area used to select the area which you want to print.
  • In option B, It is used to print the same data on each page. it is not used in print page order.
  • In option C, This option is available on the Home tab that is used for page break only that's why it is not correct.
4 0
3 years ago
Jennifer, a customer, informs you that unexpected icons are appearing on her system's desktop. You identify the symptoms of the
Maslowich

Answer:

B. Schedule scans and run updates.

Explanation:

With a malware infection you have to scan the computer with an antivirus immediately. Then, you run possible updates to get the system stronger.

8 0
4 years ago
g (Locate the largest element) Write the following method that returns the location of the largest element in a two-dimensional
ruslelena [56]

Answer:

The method in JAVA is shown below.

static double largest = 0.0;

   static int[] idx = new int[2];

   public static int r = 20;

   public static int c = 20;

   public static int[] locateLargest(double[][] a)

   {

       for(int j=0; j<c; j++)

 {

     for(int k=0; k<r; k++)

     {

         if(largest<a[j][k])

         {

             largest=a[j][k];

             idx[0]=k;

             idx[1]=j;

         }

     }

 }

 return idx;

   }

The JAVA program is shown below.

import java.util.Scanner;

import java.lang.*;

class program

{

   //static variables declared and initialized as required

   static double largest = 0.0;

   static int[] idx = new int[2];

   public static int r = 20;

   public static int c = 20;

   public static int[] locateLargest(double[][] a)

   {

       for(int j=0; j<c; j++)

 {

     for(int k=0; k<r; k++)

     {

         if(largest<a[j][k])

         {

             largest=a[j][k];

             idx[0]=k;

             idx[1]=j;

         }

     }

 }

 return idx;

   }

}

public class Main

{

   static double[][] arr;

   static double input;

   public static void main(String[] args){

       program ob = new program();

       arr = new double[ob.r][ob.c];

    Scanner sc = new Scanner(System.in);

 for(int j=0; j<ob.c; j++)

 {

     for(int k=0; k<ob.r; k++)

     {

         arr[j][k]=0;

     }

 }

 System.out.println("Enter the elements of two dimensional array ");

 for(int j=0; j<ob.c; j++)

 {

     for(int k=0; k<ob.r; k++)

     {

         input = sc.nextDouble();

         if(input>0)

          {   arr[j][k] = input;

          //System.out.println(arr[j][k]);

          }

         else

             break;

     }

     break;

 }

 int[] large_idx = ob.locateLargest(arr);

       int row = large_idx[0];

 int col = large_idx[1];

 double l = arr[col][row];

 System.out.println("The largest element in the user entered array is " + l);

}

}

OUTPUT

Enter the elements of two dimensional array  

1

2

3

4

5

6

7

8

9

0

The largest element in the user entered array is 9.0

Explanation:

1. The class program contains the locateLargest() method as mentioned in the question.

2. The public class Main contains the main() method.

3. User input for array is taken inside main().

4. This array is passed to the locateLargest() method.

5. This method returns the one dimensional array having row and column indices of the largest element in the array.

6. The indices are used to display the largest element in the main().

8 0
3 years ago
Draw a flowchart or write pseudocode to represent a program's logic that allows the user to enter a value. The program multiplie
PIT_PIT [208]

Ill choose flowchart. Look picture for the answer

ask me if you have any doubts about my answer.

5 0
3 years ago
What is the difference between software hardware ???
defon
Software are parts of a computer system that can be seen but not touched.

Hardware are parts of a computer system that can be seen and touched
3 0
3 years ago
Read 2 more answers
Other questions:
  • True/False: If a function is legally prototyped to return an integer value, it can return a structure member that is an integer
    11·1 answer
  • When working with data returned from a query wizard, refreshing a query occasionally produces undesired results. if this occurs,
    9·1 answer
  • Invalid length parameter passed to the LEFT or SUBSTRING function (below)".
    6·1 answer
  • Helena purchased a security software package to protect her new laptop against threats such as spyware and computer viruses. she
    14·1 answer
  • Outline the things that Mccann needs to do right away
    13·1 answer
  • What operation can be performed using the total feature ​
    13·1 answer
  • Catastrophic injuries and illnesses account for two-thirds of total health care costs in the country of Gnut. The Gnuti governme
    15·1 answer
  • If ADD = 81, BAD = 49, and CAD = 64, then what is the value of ACA?
    14·1 answer
  • Which three options below describe typographic hierarchy?
    12·1 answer
  • Which sql keyword is used to retrieve a minimum value from an attribute in a table
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!