Program to keep records and perform statistical analysis

Assignment Help C/C++ Programming
Reference no: EM131006542

1. Write a C++ template class named Label that takes a single type parameter named E and supports three methods:

a. A constructor that takes a single argument, which is the value of the label, and stores it in' an instance variable named value.
b. getValue: takes no parameters and returns value.
c. selValue: a void method that takes a single parameter of type E and assigns it to value.

2. The following declarations are given.
class Base
{
friend void Other::baz 0;
public:
virtual void foo (Base obj);
protected:
int data;
private:
int size;
};
class Derived : public Base
public:
virtual void foo (Base obj);
};
Given the following partial main program int main (void)

Base *b = new Derived; Base *a = new Base(*b); // insert statement (x) here

For each of the following pairs of statements (x), state whether they are equivalent to each other (where "equivalence" means that the same methods operate on the same parameter values). For each, give a 1-sentence justification for your answer.

i. b->foo(*a);

ii. b->foo(*b);

Suppose that a is an object of class Base, and b is an object of class Derived, and that both are declared globally. For each statement in the kit column of the table below. indicate whether the statement is allowed in the each of the scopes listed at the heads of the table's other columns. Indicate your answers by writing legal or illegal in the tables cells. Statement : In main() In A:foo0 In B:fosx) In friend function Other::baz

Statement

Main()

afoo()

bfoo()1

Other::baz

a.size=10;

 

 

 

 

b.data=20;

 

 

 

 

b.foo(a);

 

 

 

 

3. Complex number s are useful in science net and engineering applications. They have the form a *la. where a is a real number and h is an imaginary number. An example is: 1.0+2.51Xse the following class declaration for complex numbers.

*include <iostream>
class complex
public :
Complex(double re = O. double im =():
double real();
double imaginary();
void reall( double re ):
void imaginaryls (double im);
private:
double re;
double im ;
};
istream &operater >> (istream&, complex &c);

a. Explain why operator >> is defined as a nonmember function.

b. Write the code for the complexNumber operator >>. Assume that the format of the number read in is a +bi (including the "+" and the "i".

You may assume the presence of a space between the a and the + and between the b and the i. if you wish.

4 a. List out the difference between the below three lines. (3 Marlin)
- int DoSomething() throw();
- int DoSomething() throw(double);
- int DoSomething() throw(.....);

b. An exception handle: wants to re throw the exception might without processing it. How to handle the situation, explain with example?

5. a. Using new operator, show how to allocate memory for an integer Milner to a pointer in order, to make it store 3 rows and 2 columns of integers

b. With an example explain the concept of return by reference and reference parameter.

6. a. Create two classes, Apple and Orange. In Apple. create a constructor that takes an Orange as an argument Create a function that takes an Apple and call that function with an Orange to show that it works, Now make the Apple constructor explicit to demonstrate that the automatic type conversion is thus prevented. Modify the call to your function so that the conversion is made explicitly and thus succeeds.

b. Explain with an example the use of virtual base class in C++.

7. write a C++. program to keep records and perform statistical analysis for a class of 20 quizzes per semester), midterm score, final score, and total score.

The program will prompt the user to choose the operation of records from a menu as shown below:

MENU:

a. Add student records
b. Delete student records
c. Update student records
d. Son students' records by total score

Note: All students records store in a file stream.

8. A stack is a basic data structure, where insertion and deletion of items takes place at one end called top of the stack. The basic concept can be illustrated by thinking of your data as a stack of plates or books where you can only take the top item off the stack in order to remove things from it. A stack is also called a LIFO (Last in First Out) to demonstrate the way it accesses data. There are basically three operations that can be performed on stacks . They are I) inserting an item into a stack (push). 2) deleting an item from the stack (pop). 3) displaying the contents of the stack(peek), Implement it using templates.

a. throw an exception if stack is underflow( stack is empty, is doesn't have any data and trying to remove)

b. throw an exception if stack is overflow ( data inserted more than the army size)

9. You are going to develop software for the accounts department of a company. It should stow the details of the employees. Details should include the salary and profit share of the employees. The company has a policy. Wm; it will calculate the profit share of each employee by dividing the monthly profit of the company with the total number of employees. Consider the change in the number of employees (new appointments and resignations). Create two Class Company and employee

a. Use static members (function(s) and data member(s)).

b. Use appropriate initialization.

c. Use 'Mine function

d. Use class employee as friend to access the details from class company

Data Members can be: number of employees, profit of the company, salary, profit share, number of employees added or left.

Member functions can be: to get salary, to get profit of the company, to calculate a net salary of an employee, to update number employees, to display employee details.

Reference no: EM131006542

Questions Cloud

What has been their nemesis in the past : I need help determining what the major challenges that Whole Foods faces in the coming year. What has been their nemesis in the past? What do their financial reports indicate for how they've performed in the last five years?
Update account balances for the year end information by : Update account balances for the year-end information by recording any necessary adjusting entries. No prior adjustments have been made in 2015. Prepare an adjusted trial balance as of December 31. 2015.
What is it about the tone of the music : What is it about the tone of the music that you think matches the tone of the novel? The video you post should be 5 minutes OR LESS, and should be RATED G
Prepare the journal entry to adjust the bonds : Prepare the journal entry to adjust the bonds to their fair value for presentation in the December 31, 2011, balance sheet.
Program to keep records and perform statistical analysis : Create two classes, Apple and Orange. In Apple. create a constructor that takes an Orange as an argument Create a function that takes an Apple and call that function with an Orange to show that it works - Write a C++ template class named Label that..
For comic books holding price of sodas and income constant : Peter consumes comic books (c) and sodas (s). His utility over comic books and sodas is given by u(c,s) = −1 c − 1 s . His income is $10/weeks. Please do not be confused by the fact that the utility here is going to be a negative number, it has no si..
How are these reflected in their child-rearing processes : What more would you like to learn about your own culture and/or the culture of others in order to better understand yourself and ways you can work respectfully and responsively with young children and their families?
Why are some products elastic and some inelastic : Why are some products elastic and some inelastic? Why do some businesses charge consumers different prices for the goods? ( I.e. airlines,autos) What is comparative Advantage? What role does it play in international trade? Name and explain two source..
About the the previous payment : Lynn borrows $5,000 at 15 percent per year compounded monthly. She wishes to repay the loan with 12 end-of-month payments. She wishes to make her first payment 1 month after receiving the $5,000. She also wishes that, after the first payment, the siz..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Prepare an accounting for a dorm''s kitchen

The "purpose" of the program is to prepare an accounting (database) for e.g. a dorm's kitchen, to keep track of the consumption of beer for each room.

  Write a function named dietoss that simulates the tossing

Write a function named dieToss that simulates the tossing of two dice. When you call the function, it should generate two random numbers ranged in 1 to 6 and return the sum of the die's numbers. In the mail program, ask user how many times the dice s..

  Writing function that computes leap years

Write down function that computes leap years. Function prototype is as follows: Write function body which returns true if year is a leap year and false if year is not a leap year.

  Digital filtering

Write a main code that reads filter coefficient data from the file filter.txt and creates a filter, reads an input float_seq from the file input.txt, filters the input float_seq using the filterand then writes the output float_seq to the file, output..

  Requirements given in the problem statement

Develop the code that meets the requirements given in the problem statement. Use the concept of access specifiers while developing the code.

  Roman numeral equivalents of the decimal numbers

Write a program that prints a table of all the Roman numeral equivalents of the decimal numbers in the range 1 - 100.

  How many students he wants to add to each course

I need a program that will ask the user how many courses he wants to input and how many students he wants to add to each course and the name of each student.

  The limit on the amount of wage income

If the government raised the limit on the amount of wage income that is subject to the F.I.C.A. tax, this would: A. Move the Lorenz curve further from the line of income equality  B. Have no effect on the Lorenz curve

  How many elementary operations are used in algorithm

How many elementary operations are used in the following algorithm? The elementary operations are comparison operations (such as > and

  A define a structure to store roll no name and marks of a

a define a structure to store roll no name and marks of a student.b using the structure of q2. a above write a c

  Find out if damjibhai can win

Once a jewel type is removed from the necklace, all other instances of the same jewel type is treated as polished by the person who removed the jewel

  Write a function that returns the day of the year

Write a function day_of_year(month, day, year) that returns the day of the year (an integer between 1 and 366) specified by the three augments.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd