C++ Answers

Questions answered by Experts: 9 913

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

DO THIS PROGRAM AND TAKE PHOTOS OF CODES AND OUTPUT':




1.


Create a Class and initialize attribute of the following:




Class name: Student




Attribute: First Name




Last Name




Sex




Age




2.


From the created class, create 5 objects, and display it using


pretty table.

Write a function that, when you call it, displays a message telling how many times it has

been called: “I have been called 3 times”, for instance. Write a main() program that calls

this function at least 10 times. Try implementing this function in two different ways.

First, use a global variable to store the count. Second, use a local static variable. Which

is more appropriate? Why can’t you use a local variable? (


Define a class called vehicle that will store two items of information about a vehicle: The fuel capacity and the fuel consumption in kilometers per litre and prototype of four functions a default constructor and a parameterized constructor that initializes the Taxi fuel capacity to 20 litres and Taxi consumption to 10 kpl , a destructor and a friend function that uses the values from the constructors to calculates the taxi range (the maximum distance it would travel if its fuel tank is full without refueling) NB. Show only the prototype of the function in the class


Create a user-defined function that will accept a 3 x 3 matrix (2D Array), set it as a parameter. Say mad [3][3]; feel free to use your initials.

Function name should InitialsMatrix (ie. MadMatrix)

The function should store 9 values to the array; it only accept values 0 and 1.

It should be outputted in a table format

0 1 1

1 1 1

1 0 0

Display the sum of values if it is an even value

Use a double for loop to implement this

Screen Layout

Input 0's and 1's to the mad [3][3] matrix

mad[0][0]:0

mad[0][1]:1

mad[0][1]:1

mad[0][1]:1

mad[0][1]:1

mad[0][1]:1

mad[0][1]:1

mad[0][1]:0

mad[0][1]:0

Output Table Format

0 1 1

1 1 1

1 0 1

Sum is 6


mad[0][0]:0

mad[0][1]:0

mad[0][1]:1

mad[0][1]:1

mad[0][1]:1

mad[0][1]:1

mad[0][1]:1

mad[0][1]:0

mad[0][1]:0

Output Table Format

0 0 1

1 1 1

1 0 0

(Sum is not displayed because it is an odd value)




Sample Run 1:

Enter 10 integers: 1 2 3 4 5 6 7 8 9 10

2 4 6 8 10

1 3 5 7 9

Sample Run 2:

Enter 10 grades: 78 79 80 81 82 83 67 66 65 90

The highest is 90.

The average is 77.10!

Sample Run 3:

Enter 10 integers: 1 2 3 4 5 6 7 8 9 10

Sum of even: 30

Sum of odd: 25


C++ code and sample runs


1. Write a program that accepts 10 integers saves them in an array, seperates the even. Integers from the odd ones by saving them in seperate arrays, and prints the even one on the first line followed by the odd ones on the second line.

Sample Run:

Enter 10 integers: 1 2 3 4 5 6 7 8 9 10

2 4 6 8 10

1 3 5 7 9


2. Write a program that accepts up to 10 grades (double) and determines the highest grade and their average.A

Sample Run

Enter 10 grades: 78 79 80 81 82 83 67 66 65 90

The highest is 90.

The average is 77.10!


3. Write a program that accepts 10 integers, saves them in an arrays, and prints the sums of even integers and odd integers

Sample Run:

Enter 10 integers: 1 2 3 4 5 6 7 8 9 10

Sum of even: 30

Sum of odd: 25


A bag of cookies holds 40 cookies. The calorie information on the bag claims that the bag contains 300 calories. Write a program that asks the user to input that how many cookies he or she actually ate and then report how many calories were consumed


Define a class called vehicle that will store two items of information about a vehicle: The fuel capacity and the fuel consumption in kilometers per litre and prototype of four functions a default constructor and a parameterized constructor that initializes the Taxi fuel capacity to 20 litres and Taxi consumption to 10 kpl , a destructor and a friend function that uses the values from the constructors to calculates the taxi range (the maximum distance it would travel if its fuel tank is full without refueling) NB. Show only the prototype of the function in the class


write a class with name “STRING”.Assume only studio.h library is included and it is not possible to include any other library. In PRIVATE section of class there will be a character array (lets say S) and also it is possible to locate functions to this section that you want to use but not asked. In public section there will be five functions.

  1. ”set” function will take a character array as parameter and assign it to ‘S’
  2. ’print’ function will just print ‘S’ on screen
  3. ’count’ function will take character as parameter and count the first appearance of that character by counting from right and return this count number
  4. ’show’ function prints consonants in ‘S’ on screen (vowels : i,o,u,e,a)
  5. prefix - - operator will delete the first character of ‘S’

Write a program to initialize 4 integer numbers. Calculate Sum and Print it.

LATEST TUTORIALS
APPROVED BY CLIENTS