Question: Programming Exercises: a) Given a struct called Computer with following data members: struct Computer { int RAM; float speed; int hardDrive; int Cache; string processor;
Programming Exercises:
a) Given a struct called Computer with following data members:
struct Computer
{
int RAM;
float speed;
int hardDrive;
int Cache;
string processor;
};
Declare an object called myLaptop of type Computer with the following initialization for myLaptop
RAM = 8 GB
Speed = 2.4 GHz
hardDrive = 500 GB
Cache = 32 KB
Processor = I5 Intel
b) Write down the definition of a class called Fraction which has two private data members: numerator and denominator both of type integer The class also has public functions:
i) A constructor function that can be used to construct a fraction with users own chosen values of numerator and denominator
ii) A void function PrintFraction that will display the fraction
iii) A value return function FracValue that will return the value of numerator divided by denominator (which is a floating point number)
C). Define a struct FruitType to store the following data about a fruit: fruit name (string), color (string), fat (int), sugar (int), and carbohydrate (int). d). Given a class called Book which has four private members: title (string), author (string), price (float or double) and noOfCopies (an integer).
Define a constructor function that will assign the values of title, author, price and noOfCopies values from users chosen parameters, say title1, author1, price1, copies1 e) Declare an array of floating point number to store gpa of 10 students. Now write a loop to input the values of this gpa from computers keyboard.
Step by Step Solution
There are 3 Steps involved in it
Sure Ill provide you with a detailed solution for each part of the problem a Declare an object called myLaptop of type Computer To declare and initial... View full answer
Get step-by-step solutions from verified subject matter experts
