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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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