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.
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: 2. In your main class: a. Define the method addElement which takes an array of integers and an…
A: Note : - I made this code runnable So I Included the driver Code also to run the program . So this…
Q: Q. Create a class 'Student' with three data members which are name, age and address. The constructor…
A: //C++ program #include<iostream> using namespace std; //Student class class Student{…
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: This is the question: In Chapter 4, you created a class named Game that included two Team objects…
A: File name: “Team.java” public class Team{ //Declare instance variables private String…
Q: Override the parent class ToString() method to include the child class’s additional data. Create a…
A: Program coding is done in C#. Please find the program below
Q: (IllegalTriangleException) Programming Exercise 11.1 defined the Triangle class with three sides. In…
A: Given: In a triangle sum of two sides is greater than third side in java
Q: Given the FirstNames Array of 5 elements Bill Jack Jim Joan Fred What would FirstNames(5)…
A: "Since you have asked multiple questions I am solving the first 2 for you if you want answer for a…
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: B. Menl Clas 1. The meal class is defined by two properties: a. Name b. An ArrayList of Food objects…
A: ArrayList is a collection available in util package getCalories() method in Food class will give us…
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: Create a program named FriendList that declares an array of eight Friend objects and prompts the…
A: using System;using System.Collections.Generic;using System.Linq;using System.Text;using…
Q: Part A Write a class Bill containing the following attribute: V ID: The Bill number of type int V…
A: Solution: Java Program: import java.util.*; public class Bill { // Declare variables //…
Q: There is a PayRoll Class that has data members for an employee’s hourly pay rate, number of hours…
A: Programming instructions for the revised version of program and PayRoll: Declare a variable named…
Q: Using the Automobile class you created Chapter 10, Programming Exercise 5A as a base, derive a…
A: using System; using System.Collections.Generic; using static System.Console; class AutomobileDemo2 {…
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 a class named StockPrice. The class constructor should accept an array of stock prices as its…
A: First of all ,you need to create a class .The class name is StockPrice in which you need to create…
Q: 1. Implement a class named Appointment that contains: • A private String data field named…
A: Given:
Q: Write a class named StockPrices . The class constructor should accept an array of stock prices as…
A: Actually, c++ is powerful general purpose language.
Q: 1. Implement a class named Appointment that contains: A private String data field named patientName.…
A: PROGRAM CODE: import java.util.Scanner;public class Main { public static void main(String[] args)…
Q: Create a test program for the classes shown in part 1. Assume that all the classes are implemented…
A: Code: import java.util.ArrayList;import java.util.Scanner; class Disk { String title; int…
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: In this task, you are going to be implementing a sorted array of angle measurements modelled as…
A: The class contains two double variables. It consists of a default constructor, getter and setter…
Q: 2. Design a class named Aquarium that has As data fields Three double data fields length, width, and…
A: First of all, we need to define the Fish class in which name attribute is define and that be…
Q: Write a program that creates a class called student. The data members of the class are name and age.…
A: Note: Since you have not provided the language to write the code so I am using Java language to…
Q: Write a Program to define a Mobile class, with member variables o String brand; o double price o…
A: import java.util.Scanner;import java.io.*; class Mobile{ private String brand; private final…
Q: Create a class named Contact with the following attributes : First name, Middle name, Last name,…
A: JAVA SCRIPT CODE HERE <script> function Submit(){ var emailRegex =…
Q: The local Driver's License Office has asked you to writea program that grades the written portion of…
A: The below given java program will obey the following rubrics:Importing essential header…
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: Create a class called Rational for performing arithmetic with fractions. Write a program to test…
A: Sample output:
Q: The following class maintains an account balance and returns a special error code. public class…
A:
Q: a. Create a class called Building that has three private data members: name (String), number of…
A: class Building{ //Building has 3 private members name, flats, roomsPerFlat private String name;…
Q: Build a class Person with the following data members/instance variables a. Name b. Pet [] pets; This…
A: public class Person{ private String Name; //declare instance variables private Pet[]…
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: Write a program that calculates the average of upto 100 English distances input by the user. Create…
A: void Distance::div_dist(Distance d2, int divisor) { float fltfeet = d2.feet +…
Q: publishing company
A: Program import java.util.Scanner; class Publication { private String title; private…
Q: 1. TestScores Class Vrite a class named TestScores. The class constructor should accept an array of…
A: Lets see the solution.
Q: Write all constructors and setters getters for that class. Also overload the following operators:…
A: To write a class MyClass and to include all attributes. A constructor in C++ is a special method…
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: Write a program contained a class Student which has firstName, lastName, mark, grade. The program…
A:
Q: Create a test program for the classes shown in part 1. Assume that all the classes are implemented…
A: Solution - Programming language - Java All subparts are answered in same program code, their…
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: 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: You will design and implement your own data class. The class will store data that has been read as…
A: Required: implement a class that will store data that has been read asuser input from the keyboard…
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: You are required to design an BeautyProduct class which has following attributes String…
A: The Java Code is written below
Q: public abstract class Shape { public Shape() { } public abstract double area() ;…
A: Hey there. The code has been written in java in the next step2. I have made the code bold - texted…
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.
Step by step
Solved in 4 steps with 1 images
- 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 : JavaWrite 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.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
- Write a class named StockPrice. The class constructor should accept an array of stock prices as its argument. The class should have a method that returns the average of the stock prices. If any stock prices in the array is at least 300, the class should throw an IllegalArgumentException.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…!!!!!!!!!!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
- Write a class, XXXX_TestVehicle, which does the following:1. Creates one Car object from information entered by the user.2. Creates one Truck object from information entered by the user.3. Creates an Array of Vehicles that can hold 10 objects.4. It creates up to 10 Vehicles objects from information entered by the userIn previous chapters, you have created programs for the Greenville Idol competition. Now create a Contestant class with the following characteristics: The Contestant class contains public static arrays that hold talent codes and descriptions. Recall that the talent categories are Singing Dancing, Musical instrument, and Other. The class contains an auto-implemented property that holds a contestants name. The class contains fields for a talent code and description. The set accessor for the code assigns a code only if it is valid. Otherwise, it assigns I for Invalid. The talent description is a read-only property that is assigned a value when the code is set. Modify the GreenvilleRevenue program so that it uses the Contestant class and performs the following tasks: The program prompts the user for the number of contestants in this years competition; the number must be between 0 and 30. The program continues to prompt the user until a valid value is entered. The expected revenue is calculated and displayed. The revenue is $25 per contestant. The program prompts the user for names and talent codes for each contestant entered. Along with the prompt for a talent code, display a list of the valid categories. After data entry is complete, the program displays the valid talent categories and then continuously prompts the user for talent codes and displays the names of all contestants in the category. Appropriate messages are displayed if the entered code is not a character or a valid code.This assignment uses the same account class created in Lab #4 with a more generally useful interface. It reads commands from a bank.txt file. Your program must process the followingfour commands. Create account amountDeposit account amountWithdraw account amountBalance account In all of the above commands, account is an integer and amount is a double. The following program behavior is required –1. Valid account numbers are 1-9. This requires the program to have an array of references to Account objects.2. If the first word on any line contains a command other than the four listed above, an error message should be displayed and that line ignored.3. The create command creates a new account object with the given account number and initial balance. If an account already exists with that number an error message should be displayed and the command ignored.4. The Deposit and Withdraw commands perform the indicated operation on an existing account. If no account with that number has been…
- Using the Automobile class you created Chapter 10, Programming Exercise 5A as a base, derive a FinancedAutomobile class that contains all the data of an Automobile, plus the following field: AmtFinanced - The amount financed (a double) Override the parent class ToString() method to include the child class’s additional data. Create a program named AutomobileDemo2 that contains an array of four FinancedAutomobile objects. Prompt the user for all the necessary data, and do not allow duplicate ID numbers and do not allow the amount financed to be greater than the price of the automobile. Sort all the records in ID number order and display them with a total price for all FinancedAutomobiles and a total amount financed. For example, the output should be in the following format: Summary: FinancedAutomobile 1 2017 Honda Price is $26,000.00 Amount financed $12,000.00 FinancedAutomobile 4 2019 Honda Price is $36,000.00 Amount financed $0.00 FinancedAutomobile 5 2016 Toyota Price is $30,000.00…Using the Automobile class you created Chapter 10, Programming Exercise 5A as a base, derive a FinancedAutomobile class that contains all the data of an Automobile, plus the following field: AmtFinanced - The amount financed (a double) Override the parent class ToString() method to include the child class’s additional data. Create a program named AutomobileDemo2 that contains an array of four FinancedAutomobile objects. Prompt the user for all the necessary data, and do not allow duplicate ID numbers, and do not allow the amount financed to be greater than the price of the automobile. Sort all the records in ID number order and display them with a total price for all FinancedAutomobiles and a total amount financed. For example, the output should be in the following format:Modify the attached code: Create a new class called CalculatorWithMod. This class should be a sub class of the base class Calculator. This class should also have an additional method for calculating the modulo. The modulo method should only be seen at the sub class, and not the base class! Include exception handling for instances when dividing by 0 or calculating the modulo with 0. You would need to use throw, try, and catch. The modulo (or "modulus" or "mod") is the remainder after dividing one number by another.Example: 20 mod 3 equals 2Because 20/3 = 6 with a remainder of 2 Refer also to the attached sample outputs: