Problem 1:
For the subway system in C++ City, USA has three fee classifications: student (17 years or less), adult, and senior (65 years old or more). Write a program that counts how many of each fee classification rode the subway on a given day. Assume that the subway conductor has a laptop PC that runs your program. The conductor enters the age of each customer as the subway is under way. Your user instructions tell the conductor to enter a sentinel value of -1 at the end of the day to terminate the entry process for that day. After the sentinel value is entered, the program must display the number of customers in each fee category.

Problem 2:
Write a program that will obtain any two integers between 2 and 10 from the user and display a multiplication table. For example, if the user enters the values 4 and 5, the table would be:

1     2    3    4    5
2     4    6    8    10
3     6    9    12   15
4    8    12   16   20

If the user enters the values 3 and 2, the table would be:

1 2      
2 4         
3 6         

Problem 3:
Please write a program that asks users to input up to 20 positive integers, and then save them into an array. Finds the maximum, minimum and average of the numbers that were entered. You can use -1 to terminate your input.
To find the smallest element in an array, you only need to find the index of the smallest number. You can use the following function to do this.
int index_of_smallest(const int a[], int start_index, int used_size) {
int min = a[start_index], index_of_min = start_index;
for(int i = start_index+1; i < used_size; i++){
if(a[i] < min) {
min = a[i]; index_of_min = i;
} return index_of_min;

Note that you can write two more functions:
1) One similar to the one that finds the index of smallest number for finding the index of the largest number; and
2) one that computes the average and returns it to the main.   

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

// Subway.cpp : Defines the entry point for the console application.
//This program is to count the number of patrons in the subway. First, a patron's age
// is entered. Next, the number of various customers is calculted. Finally, the counts
//    are displayed.

#include "stdafx.h"
#include <iostream>

using namespace std;
//Beginning of Main Function
int _tmain(int argc, _TCHAR* argv[])
int age=0,cCnt=0,aCnt=0,sCnt=0;

//Enter age until the sential value being -1 to stop the loop

cout << "\nPlease enter customer's age: " << endl;
cin >> age;

//Count according to age
if (age<=17)
else if(age>=18 && age<=64)
else if(age>=65)

$25.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats