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

What is operator overloading? Explain this concept and provide a suitable example.

You are working as a computer engineer in a firm where your task for this week is to



model a Counter class in C++. You are asked to:



• Have a default constructor



• Have a constructor which should take an initial value of count



• Have a copy contractor



• Have a print function to print the count value



• Have a ++ increment operator overladed as prefix and postfix operator



• Have a -- increment operator overladed as prefix and postfix operator



• Have a destructor



Your task is to:



1. Draw the class diagram



2. Implement the class



3. Write the test code to test all the features of your class in the main program.

when the user enters three number show him true if the total of two numbers is equal to the third.


Write a program that prompts the user for number of students to process. The program will allow the user to enter the name of student and then it will ask for the number of marks for that student. The program will then prompt for each score and will calculate the average mark for each student. Make sure a structure ‘Student’ is defined. Use a function that prompts the user for the name of the student and number of test scores for that student. It stores the data into an array of type Student* and then returns that array. Use numTests[ ] array as an output parameter to store the number of tests for each student. This will then be passed to the display function. This function display marks and calculates the average for each student.


Sample Run:

Enter number of students: 1

Enter student 1 name: Jenny

Enter number of marks for Jenny: 2

Enter mark 1: 99

Enter mark 2: 88

=============================

Student 1: Jenny

Marks: 99 88

Average for Jenny is: 93.5%

=============================


Write a statement that calls the function IncreaseItemQty with parameters notebookInfo and addQty. Assign notebookInfo with the value returned.


#include <iostream>

#include <string>

using namespace std;


struct ProductInfo {

  string itemName;

  int itemQty;

};


ProductInfo IncreaseItemQty(ProductInfo productToStock, int increaseValue) {

  productToStock.itemQty = productToStock.itemQty + increaseValue;


  return productToStock;

}


int main() {

  ProductInfo notebookInfo;

  int addQty;


  cin >> notebookInfo.itemName >> notebookInfo.itemQty;

  cin >> addQty;


  /* Your code goes here */


  cout << "Name: " << notebookInfo.itemName << ", stock: " << notebookInfo.itemQty << endl;


  return 0;

}


Make a program that will input minutes and convert it into seconds. Your program will be terminated when you input zero in the minutes.


Make a program that will input Dollar currency, convert it into peso.

Peso= dollar currency*50.00 pesos.

Display the peso equivalent.

Your program will be terminated if the inputted Dollar currency = 0.


A weather station validates the rain into its critical level by its raindrops fell. Make program that will input number of raindrops fell, Check if raindrops fell is equal to 10,000 then display “CRITICAL RAIN”. Your program will be terminated if you input zero in the raindrops fell.


Define a function that will be given a pointer pointing to the first element of the linked list and two strings named first_string and second_string respectively. The function must search for the first_string in the list. If the list does not contain such a string, the function leaves the list unchanged. Otherwise, the function must add a new element in the linked list with the value of second_string after the first occurrence of the element containing the first_string. The function prototype should look like void add_after(node* , string , string)


The formula below decribes Newton's second law of motion



Force = Mass x acceleration



Using the variables below Write one line of code that will calculate the acceleration of a object.





// Mass in Kg



float mass = 50.3;



// Froce in N



int force = 720;



//acceleration



float accel;





//One line of code to calculate the acceleration of a object




LATEST TUTORIALS
APPROVED BY CLIENTS