Concept explainers
Write a
- e for end
- c for Clear; sets result to zero
- m for save in memory; sets memory equal to result
- r for recall memory; displays the value of memory but does not change result
You should define a derived class of the class calculator that has one more instance variable for the memory, a new main method that runs the improved calculator, a redefinition of the method hanndleUnknownOpException, and anything else new or redefined that you need. A sample interaction with the user is shown next. Your program need not produce identical output, but it should be similar and just as clear or even clearer.
Calculator on: result = 0.0
+ 4
result + 4.0 = 4.0
updated result =4.0
/ 2
result / 2.0 = 2.0
updated result =2.0
m
result saved in memory
c
result = 0.0
+ 99
result + 99.0 = 99.0
updated result = 99.0
/ 3
result / 3.0 = 33.0
updated result =33.0
r
recalled memory value = 2.0
result =33.0
+ 2
result: + 2.0 = 35.0
updated result = 35.0
e
End of program
Trending nowThis is a popular solution!
Chapter 9 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Additional Engineering Textbook Solutions
Starting Out with C++: Early Objects
Starting Out with C++: Early Objects (9th Edition)
Java How To Program (Early Objects)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Database Concepts (8th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
- Download the file Insect.cpp(mentioned below) and use this as your start file. Inside the file you will see the implementation of the class Insect. Do the following: a. Write a class BumbleBee that inherits from Insect. Add the public member function void sting() const . This function simply prints "sting!" and a newline. b. Write a class GrassHopper that inherits from Insect. Add the public member function void hop() const . This function simply prints "hop!" and a newline. When you are done your program output should look exactly like the output provided at the end of the file. insect.cpp #include <iostream>using namespace std; // Insect class declarationclass Insect{ protected: int antennae; int legs; int eyes; public: // default constructor Insect(); // getters int getAntennae() const; int getLegs() const; int getEyes() const; }; // BumbleBee class declaration // GrassHopper class…arrow_forwardWrite a program in Java that handles the order list for an online retailer. Your program should contain a minimum of three classes: Order Class Display Class Main Class Create a Order Class that uses a queue to hold the orders in the order they were taken. The queue should contain the customer last name, order number, and order total cost. Create a Display Class that will store a copy of the order queue in two arrays. Each array will contain the order list but one will be sorted by name and the other sorted by order number. When a order is taken and stored in the Order Class the program will update theDisplay Class arrays automatically sort them in descending order using quick sort and outputs the the contents to the console upon each entry of new data. Create a Main Class that will handle operator data input and when an order is added or removed, the program will update the Order Class and Display Class. The user will be presented a menu to add a order, remove a order and display…arrow_forwardComputer Science You are required to develop a small chatting application where two or more friends can communicate each other through messages. Create a class Message which has Date d, and message (string). Provide getters/setters, constructors, toString. Create a class Friend having String name, String contact, email and ArrayList of Messages provide getters/setters, constructors, toString addMessage(Message m) method which will add new message to the list. Provide following options to the user using JFrame. Login which will help user login to the application. View Friends (Display List of All Friends) View Messages ( This should display all message of a Friend) Send message (This should ask for friend name and message match the friend name and write that message to the array list).arrow_forward
- Create a class IntArray. Create two constructors. Nullary constructor create an array of size 10 and initiazes all values to 0. Parametrized constructor has signature IntArray(int num, int s). Thiscreates an array of size s and initializes all values. c++arrow_forwardWrite a C++ program that will display multiple-choice trivia questions, accept the user's answers, and provide a full key and a score at the end. Design and implement a class called Question. The Question class contains the following information: a stem (the text of the trivia question) an array of 4 multiple choice answers (the text of each possible answer) the letter of the correct answer (A, B, C, or D), called the key. This class will be used to represent trivia questions in a trivia game. The following operations should be available for Question objects (use the provided names). Construct a Question with no values (use empty strings for stem and answers and 'X' for the key). Construct a Question given its 3 components (). setStem: Set the stem question. getStem: Return the stem question. setAnswers: Set the 4 answers given an array. The answers will NOT include the letter (A, B, C, or D). getAnswer(i): Return the single answer at index i. setKey: Set the key letter. getKey:…arrow_forwardWrite the source code of the class CrewMember. A crew member cannot change its duty type. For example, a hostess can never become a pilot. The number of years to become a senior member should be obtained from the class FlightRules. How can we write FlightRules class its enough for me?arrow_forward
- Language - Java Create a utility class called DuplicateCounter. Create an instance method called count that takes a single parameter called dataFile (representing the path to a text file) and uses a Map of Strings to count how many times each word occurs in dataFile. The counts should be stored in an instance variable called wordCounter. Create an instance method called write that takes a single parameter called outputFile (representing the path to a text file) and writes the contents of wordCounter to the file pointed to by outputFile. The output file should be overwritten if it already exists, and created if it does not exist. Create a separate class called Application that contains a main method which illustrates the use of DuplicateCounter by calling both the remove and write methods. Your input file must be called problem2.txt and your output file must be called unique_word_counts.txarrow_forwardJava programming - please see attched image for initial instruction before the following below. Write a subclass of VowelSeparator that adds three additional methods and a constructor. The class should be named VowelSeparatorAndCounter. Here are the methods to add: void setString(String s) This method should replace the string stored by the object with s. If the argument is null then the method should throw an IllegalArgumentException. (This is an unchecked exception) int getVowelCount() This method should return the number of vowels in the string.int getNonVowelCount() This method should return the number of characters in the string that are not vowels. Write a static method that accepts an array of VowelSeparatorAndCounter objects and returns the total number of vowels contained in all of them. It should have the following signature: public static int totalVowelCount(VowelSeparatorAndCounter[] a)arrow_forward1. Implement the above system using inheritance in the best possible way. Keep every object size as small as possible. Implement all methods (setter/getter/constructors and destructors) Note that the region area is 0 while the city is len*width and the country is the sum of their cities. 2. Create array of countries called Arab of 22 countries, Write a function fill that fills the arrav Arab 3. Write a method that finds the city that has the max area in a country 4. Write a method that sorts the cities in a country from the largest to the smallest area 5. Write a function that retums array of countries of the same area of Arab 6. Write a function that compares between two countries. It returns true if countryl area greater than country2 area. 7. Write a function to move a city from one country to another.arrow_forward
- # objected oriented programming in Python I need the solution of all below python question codes along with correct return. # 1. Implement a class named "MyClass"# This class should have:# * During instantiation of this class, the 'some_val' parameter should be set as# a variable with the same name in the instance# * Implement the method called 'plus_n' that takes one parameter (named 'n'), such that# it should return the sum of instance's 'some_val' variable and 'n'class MyClass: def __init__(self, some_val): # your code goes here instead of pass pass def plus_n(self, n): # your code goes here instead of pass pass ########################################################################################################################################################################################################################################## # 2. Given two classes 'Animal' and 'DigestiveSystem, implement, using COMPOSITION the method…arrow_forwardPython:Please read the following. The Game class The Game class brings together an instance of the GameBoard class, a list of Player objects who are playing the game, and an integer variable “n” indicating how many tokens must be aligned to win (as in the name “Connect N”). The game class has a constructor and two additional methods. The most complicated of these, play, is provided for you and should not be modified. However, you must implement the constructor and the add_player method. __init__(self,n,height,width) The Game constructor needs to initialize three instance variables. The first, self.n, simply holds the integer value “n” provided as a parameter. The second, self.board, should be a new instance of the GameBoard class (described below), built using the provided height and width as dimensions. The third, self.players, should be an initially empty list. add_player(self,name,symbol) The add_player method is provided a name string and a symbol string. These two values should be…arrow_forward/*** This class describes a tweet. A tweet has a message in it, a unique ID,* a count of the number of likes, and a count of the number of times it* has been retweeted. In addition, the Tweet class will have a static * variable to count the total number of tweets to ever be created * (retweets don't count as a new tweet).* * You may NOT import any library class.* * **/public class Tweet { /*** This constructor creates a tweet with the given message.* Assume that the message is not null because only the tweet() method* from the TwitterUser class will call this constructor. There are* no length requirements on Tweets.* * The very first tweet to ever be created will have an ID of 0, the * next one will have 1, and so on and so forth. It may help you to use* the static count variable to set the ID. * * You will have to initialize other instance variables appropriately.* @param message the text of the tweet*/public Tweet(String message) {throw new UnsupportedOperationException("Implement…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education