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

Apply algorithms which perform following operations on Arrays and Linked List.
b. Searching of Elements
i. Linear Searching of Elements
ii. When Linked List is unsorted
iii. When Linked List is sorted
#include <iostream>
#include <cstring>
#include <fstream>
#include <ctime>
#include <conio.h>
using namespace std;
time_t t; // t passed as argument in function time()
struct tm * tt; // declaring variable for localtime()

struct customer{
char phone[22];
char name[20];
char address[50];
};

struct reservation{
int yearday, month, date;
int customerid[20];//note that array index is hotel room number.
};

reservation rese[366];

void addcust(){
// Max Marks 5
//You are required to add customer in a
// customer file with attributes as given in struct customer.
}
The athletics department of a university gives athletes a cash bonus after completing an event as follows:  A bronze medalist gets a 10% cash bonus,  A silver medalist gets a 12% cash bonus and  A gold medalist gets a 15% cash bonus.  All the other athletes get a 5% cash bonus if they are placed among the first 6 athletes. You are requested to write two versions of a program that calculates and displays the final amount that is due, after discount. (i) (ii) Hint: The first version of the program uses a switch statement to implement the above program. The second version of the program uses nested-if statements. Use the following variables: float amount; // the amount that can be divided between the // athletes char athleteCategory;// the medal recieve: 'G' (gold) or // 'S' (silver) or 'B' (bronze) or // 'P'(places) float cashBonus;
A fruit packing company needs to divide a freight of oranges in different quantities according to the size of boxes that must be packed. For example, for South America boxes must contain 36 oranges; for Europe boxes must contain 24 oranges. You are required to write a program to determine the number of boxes as well as the number of oranges left after packing. There are 1256 oranges in the load. The program has the following structure: Declare three int variables nrOranges, nrBoxes, and nrLeft. nrOranges represents the number of oranges in the load, nrBoxes represents the number of boxes packed, and nrLeft represents the number of oranges that is left. Assign the value 1256 to nrOranges.
Write the statement to calculate the number of boxes of size boxSize. Write the statement to calculate the number of oranges, if any are left.
Define a class called Odometer that can be used to track fuel and traveling distance for a car. Include private member variables to track the distance driven (in kms) and the fuel efficiency of the car in kilometers per liter. The class should have a constructor that initializes these values to zero. Include  a default constructor to initialize both member variables to zero,  a member function to reset the odometer to zero kilometers,  a member function to set the fuel efficiency,  a member function that accepts kilometers driven for a trip and adds it to the odometer’s total,  a member function that returns the number of liters of fuel that the car used since the odometer was last reset (this can be calculated using the distance driven and the fuel efficiency), and  a destructor. Use your class with a test program that creates odometers for different cars with different fuel efficiencies. Let the cars do several trips. Reset the odometers at the start of your program.

Define a class Pairs with 2 integer data members, f & s, where f represents 

the 1st value in the ordered pair and s represents the 2nd value. Objects of type Pairs can be used wherever ordered pairs are 

needed.

The class must have a default constructor that initializes data members to 

0, & 2overloaded constructors, 1 with one int parameter and the other with 

2 int parameters. The 1-parameter constructor should initialise the 1st 

member of the pair; the 2nd member of the pair must be 0. The 2-parameter 

constructor must initialise both members of the ordered pair.

The class must have a destructor that outputs 'Bye'

Add accessor functions that return the values stored in each of the member

variables of an object of class Pairs & mutator functions to update each of the member variables of an object of class Pairs

respectively. The class must contain a void member 

function reset() that resets the member variables of a Pairs to values 

specified by parameters.


Write a program having following classes

Player (Base Class)

Members:

  • Show_Stats()
  • Other class variables and functions

Cricket player (Derived Class)


Members:

  • Show_Stats
  • Other class variables and functions

Hockey player (Derived Class)

Members:

  • Show_Stats
  • Other class variables and functions

Football player (Derived Class)

Members:

  • Show_Stats
  • Other class variables and functions


  • In the main function, make objects of each derived class and use their functions to show players statistics (e.g. for cricket player: Runs scored, Wicket taken etc. Similarly for Football, Goals scored etc)
  • Common variables/functions should be part of base class and additional members of each derived class will be part of them




Write a basic while loop with a function code in the program that sums a stream of integers (input from the keyboard) and continues to do so while the integer entered is not -999. Ask the user to enter values in the range of 1 to 10000 or -999 to quit.


create a class same as int bultin data type which will initialize its member data from zero or from some other value. the variable of this class work with unary operator with prefix or postfix astrics

Design four classes: Student, Exam ,Sports and Result.  The Student class has data members such as reg. number, name. Create Exam by inheriting the Student. The Exam class adds data members representing the marks scored in 3 subjects. Create Sports by inheriting the Student. The Sports class adds data members representing the marks scored in indoor and outdoor games. Derive the Result from the Exam , Sports and Result  has its own data member of Total mark. Write an interactive program with appropriate member functions to model this relationship.


LATEST TUTORIALS
APPROVED BY CLIENTS