Creates a Breakfast class
Q: 2. Complete the class code below and using only the main method, add code to make an EXACT COPY of…
A: [Note: Explanation of the program code is provided within the comments.] Program code:…
Q: Write a program that contains a class called Student with data members for storing student 5 digit…
A: import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner…
Q: Write a program to create a class” Fan “to represents features of a fan as follows: “Fan “should…
A: Given: Write a program to create a class” Fan “to represents features of a fan as follows: “Fan…
Q: Which of the following is true in case of destructors I. Destructor function is automatically…
A: C++ makes use of constructors and destructors. Constructors: They are special class function that…
Q: add override display method using System; //base class class Book{ //data members private string…
A: In C#, method overriding is similar to the virtual process in C++. Method override is a…
Q: Place the CashRegister calss in a file called cashregister.py and write following test code in the…
A: Python: Python is a high-level , interpreted language with easy syntax and dynamic semantics. Python…
Q: public class FirstEx_2ExplainCodes { static int counterObj= 0; public double salary = 0; public…
A: EXPLANATION: - class FirstEx_2ExplainCodes comprises of following variables: - static integer…
Q: Instructions Reverse4.cs + 1 using static System.Console; 2 class Reverse4 Create a new program 3 {…
A: The reverse is a methodology which is used to reverse the characters in the stringbuffer.
Q: This is in Java please: A comma separated value (.csv) file has been included to be used for this…
A: Actually, java is a object oriented programming language.
Q: If the following compiles, what will be displayed when main () is executed? public class Doctor{…
A: Doctor class has a member variable, billableRate = 100.0 with access modifier protected. That means…
Q: What is the output of the following program? #include #include using namespace std; class A {…
A: To do: Output of the given code:
Q: 11. Suppose your program contains the following class definition: class myClass ( public:…
A: Your answer is given below with proper explanation.
Q: amount the same, y, n, why? public class CheckingAct { private String actNum;…
A: 1. If you declare any variable in the methods then they are local variable and scope of variable is…
Q: For this exercise, you will create 2 classes: InputOutput class and AddNumbers class. ⦁ InputOutput…
A: Program code: File name: InputOutput.java //import the required packagesimport java.io.File;import…
Q: Choose the best statement below: Consider the following code: class A { public: virtual…
A: c.) This code compiles, and there is no example of polymorphism in the code.
Q: Create a class Employee with name, Id and salary as data members. Provide appropriate constructors,…
A: Given:-
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: 1. You are to write a simple program with two classes. One controller class and a class to hold your…
A: Here is the solution:- Explanation Created two classesController class - Gets input from the…
Q: // Creates a Breakfast class // and instantiates an object // Displays Breakfast special information…
A: Given Program: using System;using static System.Console;using System.Globalization;class DebugNine2{…
Q: Show the printout of the following program:class A:def _ _new_ _(self):print("A's _ _new_ _()…
A: The given code defines two classes named "A" and "B". Class "A" defines the function "new()" and…
Q: Write a program that: • defines a class Song, with attributes title, artist. o include_init_0…
A: You didn't specify any language for the question, So i am doint it in Python. class Song: # defining…
Q: What will the following program display? #include <iostream> using namespace std; class…
A: Code #include <iostream> using namespace std;class First{protected: int a;public:First(int x =…
Q: In this program write in pseudocode, Thankyou Public Class Test Public Shared Sub Main()…
A: Every code is considered as the psuedocode . To convert any perfect code to psuedocode we just have…
Q: c. What RuntimeException will the following program throw, if any? public class Test { public static…
A: According to the provided information: We need to find out the exception given by the program.
Q: Q2: Continue with Animal class: a) Copy the previous program to a new file. b) Write Constructor…
A: #include <iostream>using namespace std; class Animal{ private: string species;…
Q: 1. In the CheckingAccount class: a. Create one method for depositing. The deposit method should…
A: import java.util.Scanner; class AccountBalance { private long accountNumber; private String…
Q: 1. Replace the (????) with relevant code to make th eprogram function. Details about the code are…
A: hasNextLine() is used to check whether there is next line or not whereas hasNext() is used to check…
Q: PLEASE REWIRETE THIS CODE USING "The J Option Pane Class" import…
A: The JOption Pane class is used to provide standard dialog boxes such as message dialog box, confirm…
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: Write a program to simulate a login. Create a class user which has a user name, a password, and a…
A: The complete program is solved using java programming language:
Q: Create a class Worker with instance variables worker_name, worker_rate_hour,…
A: Classes is a way by which encapsulation is implemented as data and its functions are under one name.…
Q: Given an incomplete program in Program 3: ITE //Program 1 Declare class named Daisy that inherits…
A: Here we have given the code in java as per the requirement. you can find the solution in step 2.
Q: 1. Implement the class bill: a. Write the constructor that takes as parameters all data fields…
A: the code is an given below :
Q: B1. Answer the following questions: a. Given: class A { class Cextends B { public String toString()…
A: Please find the program and output in the below steps.
Q: Examine this code and determine what happens when it is run: 1 public class Test { int x; 2 public…
A: In Java, the default value of the instance variable is initialized with 0 when the object of the…
Q: Need dry run for given main file code. Main file: MultiItemSaleTest.java public class…
A: Let's assume that there are three classes Sale, DiscountSale and MultiItemSale. Classes…
Q: Write a program that can have a student class (id, name, CGPA, get_CGPA()) if the CGPA is less than…
A: Catch block is used to handle an Exception that interrupts normal flow of program
Q: Please read all parts of this question before starting the question. Include the completed code for…
A: A class is a group of objects which have common properties. A constructor is a method that is used…
Q: Suppose a program has the following class declaration: class CheckPoint {private: int a;protected:…
A: Given: Suppose a program has the following class declaration: class CheckPoint {private: int…
Q: #include using namespace std; class A { private: int x; public: A(int _x) { x = _x; } int…
A: According to the question below the solution:
Q: Only___________ data members of a class can be accessed by a derived class. Private and public…
A: There are three questions, all are MCQ-based. The first question is directly dealing with the access…
Q: Create a flowchart base on the source code source code: import java.util.Scanner; public class…
A: The flow chart is a pictorial representation of the flow of the program. The flow chart is…
Q: ijava 23 3 public class Paintl { public static void main (String [] args) { Scanner scnr = new…
A: I have used try-catch statements to handle cases when user entered data other than double type (i.e…
Q: How to expplain this pseudo code? START Public Class BankingSystem Declarations…
A: A plain language which is use to describe any algorithm or any system, is called pseudo code.…
Q: a. Give a brief description of the problem (Specification and assumptions) public class…
A: The program has the following parts: (a) int presentReading = 0, previousReading = 0;Scanner kbd =…
Q: Write a Fraction class that works with the FractionMath program above. It should use your…
A: The given FractionMath Main Program is: //FractionMath class public class FractionMath {…
Q: This is a debugging problem - The files provided in the code editor to the right contain syntax…
A: import java.util.*; public class Main { public static void main(String args[]) {…
Q: this is my code about the Pig Latin Language. What did I do wrong, please? using static…
A: Introduction of the Program: The C# program takes a word from the user and then convert it into Pig…
Q: Consider the following code:Which one of the following is true public class Main String name; public…
A: Given:
The provided file has syntax and/or logical errors. Determine the problem(s) and fix the program.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- Write a Fraction class that works with the FractionMath program above. It should use your Fraction.java file to run.Main Program:public class FractionMath{public static void main(String[] arguments){// create four fractions accountsFraction w = new Fraction();Fraction x = new Fraction(3,4);Fraction y = new Fraction(2,5);Fraction z = new Fraction(6,0);System.out.println("*** Does the toStringMethod work?"); System.out.println("First fraction : " + w); System.out.println("Second fraction : " + x); System.out.println("Third fraction : " + y); System.out.println("Forth fraction : " + z); System.out.println(); // Does the get() method work? System.out.println("*** Does the get() methods work?"); System.out.println("w = " + w.getNumerator() + " over " + w.getDenominator()); System.out.println();// Can we change the values correctly nameSystem.out.println("*** Does the set() methods work?");System.out.println("w fraction Before : " + w); w.setNumerator(22);System.out.println("w fraction After…Complete the following program that reads a file (where the file name is provided tothe main method as parameter) that contains the students’ information, adds 2 to thetotal marks (without updating the file), and prints student information and whether ispassed or not. public class ProcessGrades { public static void main(String[] args) throws Exception { String fileName = args[0]; Scanner s = new Scanner(Paths.get(fileName)); while(s.hasNext()) { // add you code here } }}You must pass the name of the file as option while running the file. So you can run yourprogram using a command line similar to: java ProcessGrades results.txtIt is supposed to have the following output (after running the program):100 Fahd 95.00 Passed101 Omar 52.00 Failed102 Anas 60.00 PassedGiven the following definition of the classes Person, Father, and Home,which option, if used to replace/* INSERT CODE HERE */,will cause the code to compilesuccessfully (select 3 options):class Person {}class Father extends Person {public void dance() throws ClassCastException {}}class Home {public static void main(String args[]) {Person p = new Person();try {((Father)p).dance();}//INSERT CODE HERE}}Question options: catch (NullPointerException e) {}catch (ClassCastException e) {}catch (Exception e) {}catch (Throwable t) {} catch (ClassCastException e) {}catch (NullPointerException e) {}catch (Exception e) {}catch (Throwable t) {} catch (ClassCastException e) {}catch (Exception e) {}catch (NullPointerException e) {}catch (Throwable t) {} catch (Throwable t) {}catch (Exception e) {}catch (ClassCastException e) {}catch (NullPointerException e) {} finally {}
- Modify the MilTime class given under Final exam module. The class should implement the following exceptions: BadHour Throw when an invalid hour (< 0 or > 2359) is passed to the class. BadSeconds Throw when an invalid number of seconds (<0 or > 59) is passed to the class. Demonstrate the class in a driver program. Demo in the main function. the file: // MillTIme.cpp//#include "stdafx.h"#include <iostream>using namespace std;class Time{protected: int hour; int min; int sec;public: Time(int h, int m, int s) { hour = h; min = m; sec = s; } int getHour() { return hour; } int getMin() { return min; } int getSec() { return sec; }}; class MilTime : public Time{private: int milHours; int milSeconds;public: MilTime(int h = 0, int s = 0) : Time(0, 0, s) { if (h < 0 || h > 2359) { cout << "Hours must be in the range 0 - 2359.\n"; milHours = h;…Save the following C++ program into a file classes.cpp: #include <iostream>using namespace std;class A {public:A() { x = 0;}void increment() { x++; }virtual void decrement() { x--; }void print() {cout << "x = " << x << endl;}protected:int x;};class B : public A {public:void increment() { x = x + 2; }virtual void decrement() { x = x - 2; }};int main() {A a; // a is an object of class AA * ptr; // ptr is a pointer to an object of class Aptr = &a;ptr -> increment();ptr -> print();ptr -> decrement();ptr -> print();} Compile the program classes.cpp, run it. Make sure that the program compiles and runs. Question 1. In the main function, add an object b of class B. Set the pointer ptr to point to b. Call increment() and decrement() on the object pointed to by ptr, print the object after each call. Which method gets called in each case? Why? Question 2. Add a protected variable int y to B and a constructor to initialize y to 0. Add a…Lab 9 C balance the same, y, n, why? class CheckingAct { . . . . private int balance; public void processCheck( int amount ) { int charge; if ( balance < 100000 ) charge = 15; else charge = 0; balance = balance - amount - charge ; // change the local copy of the value in "amount" amount = 0 ; } } public class CheckingTester { public static void main ( String[] args ) { CheckingAct act; int check = 5000; act = new CheckingAct( "123-345-99", "Your Name", 100000 ); System.out.println( "check:" + check ); // prints "5000" // call processCheck with a copy of the value 5000 act.processCheck( check ); System.out.println( "check:" + check ); // prints "5000" --- "check" was not changed } }
- Place the CashRegister calss in a file called cashregister.py and write following test code in the cell below. a Complete following test code: Import all methods of CashRegister class Write a test function to test the getTotal() and getCount() methods as it follows. add 5 items. undo the last item. add 3 more items. undo the last item after your test has done all of the above, print an statement for expected total price and total count. call the getTotal() and getCount(). (the result must be equal to the previous part) class CashRegister: def __init__(self): self._itemCount=0 self._totalPrice=0.0 self._taxPercent=13 def addItem(self,price): self._itemCount=self._itemCount+1 self._totalPrice=self._totalPrice+price def getTotal(self): return self._totalPrice def getCount(self): return self._itemCount def clear(self): self._itemCount=0 self._totalPrice=0 def updateTaxRate(self,newTaxPercent): if…For this exercise, you will create 2 classes: InputOutput class and AddNumbers class. ⦁ InputOutput Class: write a program that carries out the following tasks:⦁ Create an object of type PrintWriter and that writes into a file with the name greeting.txt.⦁ Print the message “Hello, world!” on the file.⦁ Close the file.⦁ Open the same file again.⦁ Read the message into a string variable (hint: use nextLine() method to read the text).⦁ Print the message on the screen. ⦁ AddNumbers Class: write a program that asks the user to input four floating-point numbers. Add all correctly specified values and print the sum when the user is done entering data. Use exception handling to detect improper inputs. For example, the user might enter letters instead of numbers. In this case, use the exception handling mechanism to print a proper message. (hint: use InputMismatchException) Don’t forget to import java.util.*.Java Program ************This program must work in hypergrade and pass all the test cases.********** Please modify this program down below because it does not pass all the test cases. I have provided the failed test cases and the correct test case as a screenshot. import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.io.InputStreamReader; // Import InputStreamReaderpublic class WordSeparator { public static void main(String[] args) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) { String inputFileName; while (true) { System.out.print("Please enter the file name or type QUIT to exit:\n"); inputFileName = reader.readLine(); if (inputFileName.equalsIgnoreCase("QUIT")) { break; } try { BufferedReader fileReader = new BufferedReader(new…
- Consider the following code:public class Banker {private BankAccount[] accounts; public Banker(BankAccount[] theAccounts) {accounts = theAccounts;} public BankAccount[] updateOverDueAccounts() {try {for (BankAccount anAccount : accounts) {if (anAccount.getOverdueAmount() <= 250) {anAccount.setOverdueFlag();}}}catch (Exception ex) {System.out.println ("Exception: " + ex.getMessage());}return accounts;}}Calculate the following metrics (IMPORTANT: show how each value was calculated):a- The Cyclomatic Complexity of the Banker constructor methodb- The Cyclomatic Complexity of the updateOverDueAccounts methodc- The WMPC (Weighted-methods-per-class) of the Banker classd- The CBO (Coupling-between-objects) of the Banker class.Lab 9 b amount the same, y, n, why? public class CheckingAct { private String actNum; private String nameOnAct; private int balance; . . . . public void processDeposit( int amount ) { // scope of amount starts here balance = balance + amount ; // scope of amount ends here } public void processCheck( int amount ) { // scope of amount starts here int charge; incrementUse(); if ( balance < 100000 ) charge = 15; else charge = 0; balance = balance - amount - charge ; // scope of amount ends here } }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