Write a class named StockPrices . The class constructor should accept an array of stock prices as its argument. The class should have a member function that returns the average of the stock prices. If any stock price in the array is negative or greater than 5000, the class should throw an exception. Demonstrate the class in a program. Ps: Using C+
Q: Write a program to create a class named Student. Student class have two sub classes UnderGraduate…
A: Define a class Student. Define two data members name and age inside it. Define a sub class…
Q: Write in c++ language: Your program will have a class called FlightController that is going to be…
A: Please complete the code given as referred in step 2.
Q: A pedometer treats walking 2,000 steps as walking 1 mile. Write a steps_to_miles() function that…
A: Formula to find the number of miles travelled for a given number of steps: ONE_MILE=2000NUMBER OF…
Q: Write a program which has a class called Area and appropriate member functions to get input from the…
A: Program code: //main.cpp#include<iostream>using namespace std;//Area classclass Area{private:…
Q: Write a program which has a class called String containing a character array as a data member. The…
A: Write a program which has a class called String containing a character array as a data member. The…
Q: Write a class named TestScores. The class have an integer array to store test scores, provide…
A: CODE:- TestScores.java import java.util.Scanner;public class TestScores { private double…
Q: Write an application that displays a series of at least 10 student ID numbers (that you have stored…
A: The main objective of the program is to create two classes called GradeException.java and the other…
Q: Modify the attached code: Create a new class called CalculatorWithMod. This class should be a sub…
A: Given: Modify the attached code: Create a new class called CalculatorWithMod. This class should be…
Q: 11. Suppose your program contains the following class definition: class myClass ( public:…
A: Your answer is given below with proper explanation.
Q: Modify the Loan class definition in the program ex91.cpp to include a new class called Bank in its…
A: ############ Contact.h ########### class Contact{ private: int part1; int part2;…
Q: Write a class named StockPrices . The class constructor should accept an array of stock prices as…
A: public class StockPrices { double stockPrices[]; public StockPrices(double prices[]) {…
Q: Write a class named TestScores. The class have an integer array to store test scores, provide…
A: [Program Code]: public class TestScores { int[] scores;…
Q: for c++ please pleaseneed two files which are employee.h productionWorker.h NB: please pleae…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: Write an application that displays a series of at least 10 student ID numbers (that you have stored…
A: public class GradeException extends Exception{ public static char[]…
Q: 1. Create a class named Contact with the following attributes : First name, Middle name, Last name,…
A: Since you have asked multiple questions in a single request, we will be answering only the first…
Q: 1. If a class declaration does not specify extends and a class name to the right of the new class…
A: A class is combination of data members and methods which are put together within block. Java…
Q: Create a class called employee with the following details as variables within it. 1. Name of the…
A: Given: Create a class called employee with the following details as variables within it. 1. Name of…
Q: Write a program that converts a number entered in Roman numerals to decimal. Your program should…
A: SOLUTION: #include<iostream.h> #include<conio.h> #include<string.h> class…
Q: Write an application that displays a series of at least eight student ID numbers (that you have…
A: File name: “GradeException.java” //Define the GradeException class that extends "Exception" class…
Q: Q1: Implement a class called Animal. a) A class named Animal b) Private data members: species and…
A: The given problem is related to Object-Oriented programming where a Class Animal and a driver main…
Q: for each field. Upon construction, throw a CourseException if the department does not consist of…
A: //CollegeCourse class public class CollegeCourse { // data fields String department; int…
Q: The following class maintains an account balance and returns a special error code. public class…
A:
Q: Write an application that displays a series of at least eight student ID numbers (that you have…
A: Java allows us to create our own exceptions which are basically derived classes of Exception. The…
Q: I am not sure how to ask this question, but I need help in understanding the usage of :: when…
A: given: void add_name(string name){ class_name::variable_name = name; }
Q: Your program must process the following four commands. Create account amount Deposit account amount…
A: /** * This class performs bank operations*/public class Account { private int accNumber;…
Q: Need Q. sap in JAVA 1. Create a class named Contact with the following attributes : First name,…
A: /******************************************************************************…
Q: Create a class called employee with the following details as variables within it. 1. Name of the…
A: Answer :- #include<iostream> #include <string> using namespace std; class Employee {…
Q: Create a class called employee with the following details as variables within it. a). Name of the…
A: An array is a linear data structure that has elements arranged in sequential order. This is similar…
Q: Create a class called employee with the following details as variables within it. a). Name of the…
A: Class is a user-defined data type in which it consists of data members and member functions. In this…
Q: Q1: Implement a class called Animal. a) A class named Animal b) Private data members: species and…
A: #include <iostream>using namespace std;//implementing Animal class//Aclass Animal{…
Q: Consider the following code: public class Banker { private BankAccount[] accounts; public…
A: Consider the following code:public class Banker {private BankAccount[] accounts; public…
Q: Can i get solution for b a. Create a CourseException class that extends Exception and whose…
A: EXCEPTION HIERARCHY IN JAVAChecked ExceptionUnchecked/Runtime ExceptionError Checked exception is a…
Q: /Animal.cpp is the main function file of the Animal class //CSIS 112/B16 #include using namespace…
A: Actually, program is an executable software that runs on a computer.
Q: Write a class named TestScores. The class constructor should accept an array of test scores as its…
A: c ++ code is an given below : #include <iostream> using namespace std; class TestScores {…
Q: class gene { public: gene( ); gene(string n, string cl); string get_genename( ); //required…
A: (a) class gene{ public: gene() { name=""; chromosomal_location=""; }…
Q: For the question below, assume the following implementation of an Employee class: 1 class Employee {…
A: In this problem, we need to figure out what is going why we are getting Null pointer exception. So…
Q: Create a CourseException class that extends Exception and whose constructor receives a String that…
A: public class Course {private String department;private int courseNumber;private float credits;public…
Q: For this lab, you will practice creating a class named 'Date' in separate files: Date.h and Date.cpp…
A: class Date{ private: int day, month, year; public: void setDate(int day, int…
Q: Which of the following are not true about polymorphism? A It means single form. B It is the passing…
A: Option which is not true about polymorphism
Q: Write a class named StockPrices . The class constructor should accept an array of stock prices as…
A: Program: #include <iostream> using namespace std; //class class StockPrices { public:…
Q: a) Create a data structure, UserStore (.h) to store User objects, with the following features:
A: 1. for getUserById, simply return user id of current instance 2. addUser , simply add this user…
Q: This C++ assignment uses the same account class created in Lab #4 with a more generally useful…
A: #include <iostream> using namespace std; // class class Bank { private: int acno;…
Q: for c++ please need three files employee.h productionWorker.h cpp file NB: NEED ANSWER THE…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: 2- Given a class named student, which of the following is a valid constructor declaration for the…
A: Given, To determine the valid constructor declaration for the class student.
Q: Let Course be a class with a default constructor and a parameterized constructor that accepts a C-…
A: We need to choose the correct answer from the given options. We need to find that how many times the…
Q: Write a class named TestScores. The class have an integer array to store test scores, provide…
A: Code for main.cpp: #include <iostream>#include <string>#include <iomanip>#include…
Q: Language: C++ Write a Garage class that has a Car (i.e., object of a second class) that is having…
A: ANSWER:-
Q: Program to define a Mobile class, with member variables String brand; double price String OS (make…
A: Java programming is an object-oriented programming language, that's used to build web browser…
Q: Cpp program Write a Garage class that has a Car that is having troubles with its Motor. Use a…
A: Given: Cpp program Write a Garage class that has a Car that is having troubles with its Motor. Use a…
Write a class named StockPrices . The class constructor should accept an array of stock prices as its argument. The class should have a member function that returns the average of the stock prices. If any stock price in the array is negative or greater than 5000, the class should throw an exception. Demonstrate the class in a program.
Ps: Using C++
Step by step
Solved in 4 steps with 3 images
- Write a class named StockPrices . The class constructor should accept an array of stock prices as its argument. The class should have a member function that returns the average of the stock prices. If any stock price in the array is negative or greater than 5000, the class should throw an exception. Demonstrate the class in a program. This is a question of c++The following class maintains an account balance and returns a special error code. public class Account { private double balance; // returns new balance or -1 if error public double deposit(double amount) { if (amount > 0) balance += amount; else return -1; // Code indicating error return balance; } } Rewrite the class so that it throws appropriate exception instead of returning -1 as an error code. Write test code that attempts to deposit!!!!!!!!!!Below is The following class maintains an account balance and returns aspecial error code.public class Account{private double balance;// returns new balance or -1 if errorpublic double deposit(double amount){if (amount > 0)balance += amount;elsereturn -1; // Code indicating errorreturn balance;}}Rewrite the class so that it throws appropriate exception instead ofreturning -1 as an error code. Write test code that attempts to depositinvalid amounts and catches the exceptions that are thrown/. Cose
- #c++# Write a program that inputs a line of text, replaces all punctuation marks with spaces. 2.Create a class called Complex for performing arithmetic with complex numbers. Write a program to test your class. Complex numbers have the form realPart + imaginaryPart * i where i is Use double variables to represent the private data of the class. Provide a constructor that enables an object of this class to be initialized when it’s declared. The constructor should contain default values in case no initializers are provided. Provide public member functions that perform the following tasks: Adding two Complex numbers: The real parts are added together and the imaginary parts are added together. Subtracting two Complex numbers: The real part of the right operand is subtracted from the real part of the left operand, and the imaginary part of the right operand is subtracted from the imaginary part of the left operand. Printing Complex numbers in the form (a, b), where a is the real…Need Q. sap in JAVA 1. Create a class named Contact with the following attributes : First name, Middle name, Last name, Date of birth, Gender, Anniversary, Address, Area, City, Pincods, State, Country, Telephone number, Mobile number, Email, Website. (Contact.java) 2. Write a method named validate (] in the Contact class created earlier. This method must generate an exception if any of the following validation rules fail: i First name, last name, date of birth and email are compulsory. i, E-mail must be in the correct format , display correct format. iii. At least one of either telephone or mobile number must be specified 3. Implement stack for Contact objects. Use exception handling to apply the following rules: i, Apop must fail on an uninitialized stack and empty stack ii. A push must fail on an uninitialized stack and stack which is already full iii. A push must fail on a stack if the Contact object’s validation fails.Write a program which has a class called String containing a character array as a data member. The class should contain constructor for input and an appropriate member function for throwing an exception in case the ASCII value of a character is a palindrome. You may use any other data members or member functions you deem necessary for computing the answer
- in c # i need to Write the program BookExceptionDemo for the Peterman Publishing Company. Create a BookException class that is instantiated when a Book’s price exceeds 10 cents per page and whose constructor requires three arguments for title, price, and number of pages. Create an error message that is passed to the Exception class constructor for the Message property when a Book does not meet the price-to-pages ratio. Next, create a Book class that contains fields for title, author, price, and number of pages. Include properties for each field. Throw a BookException if a client program tries to construct a Book object for which the price is more than 10 cents per page. Finally, using the Book class, create an array of five Books. Prompt the user for values for each Book. To handle any exceptions that are thrown because of improper or invalid data entered by the user, set the Book’s price to the maximum of 10 cents per page. At the end of the program, display all the entered, and…in C# i need to Write the program BookExceptionDemo for the Peterman Publishing Company. Create a BookException class that is instantiated when a Book’s price exceeds 10 cents per page and whose constructor requires three arguments for title, price, and number of pages. Create an error message that is passed to the Exception class constructor for the Message property when a Book does not meet the price-to-pages ratio. For example, an error message: For Goodnight Moon, ratio is invalid. ...Price is $12.99 for 25 pages. Next, create a Book class that contains fields for title, author, price, and number of pages. Include properties for each field. Throw a BookException if a client program tries to construct a Book object for which the price is more than 10 cents per page. Finally, using the Book class, create an array of five Books. Prompt the user for values for each Book. To handle any exceptions that are thrown because of improper or invalid data entered by the user, set the Book’s…C++ Programming Use the following code, which could be added to your current file in CLion, so this code compiles and the assertion passes. This means you need to implement class AccountContainer. The member function getValue() must always return the sum of all BankAccounts. Do not hard code getValue to return 109.99. auto acct1 = shared_ptr(new RegularAccount("account", 100.00)); auto acct2 = shared_ptr(new RegularAccount("account", 9.99)); auto accounts = new AccountContainer(); accounts->add(acct1); accounts->add(acct2); assert(accounts->getValue() == 109.99);
- Write a class named TestScores. The class have an integer array to store test scores, provide getters, setters, constructor should accept an array of test scores as its argument. The class should have a member function that returns the average of the test scores. If any test score in the array is negative or greater than 100, the class should throw an exception. Also if number of values increases the array size it should throw an exception, Demonstrate the class in a program. Programming language : JavaPrevious Exercise to help with answering the question which is below | Write the header file (.h file) of a class Counter containing: A data member counter of type int. A data member named counterID of type int. A static int data member named nCounters. A constructor that takes an int argument. A function called increment that accepts no parameters and returns no value. A function called decrement that accepts no parameters and returns no value. A function called getValue that accepts no parameters and returns an int. A function named getCounterID that accepts no parameters and returns an int. #include<iostream>using namespace std; class Counter{private:int counter;int counterID;static int nCounters;public:Counter(int c);void increment();void decrement();int getValue();int getCounterID();}; ----------------------------------------------------------------------- ANSWER THIS QUESTION!In C++ Write the implementation (.cpp file) of the Counter class of the previous exercise.The…The local Driver’s License Office has asked you to write a program that grades the written portion of the driver’s license exam. The exam has 10 multiple-choice questions. Here are the correct answers: 1. B 2. D 3. A 4. A 5. C 6. A 7. B 8. A 9. C 10. D A student must correctly answer 7 of the 10 questions to pass the exam. Write a class named DriverExam that holds the correct answers to the exam in an array field. The class should also have an array field that holds the student’s answers. The class should have the following methods: • passed. Returns true if the student passed the exam, or false if the student failed. • totalCorrect. Returns the total number of correctly answered questions. • totalIncorrect. Returns the total number of incorrectly answered questions. • questionsMissed. An int array containing the question numbers of the questions that the student missed, i.e. answered incorrectly. Test the class in a separate class, DriverTest , that asks the user to enter a student’s…