Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 5.12, Problem 5.12.3CP
Rewrite the
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Create a new file in c++.
In this lab, you will add some functionality to the table ofmenu. Your boss (me) has decided that letters should be used for menu items instead of digits (because there are more alpha characters than numeric ones, so more additional menu items could be added in the future). We all know that programmers are lazy, but so are most users! So, the user should be able to enter either uppercase (A) or lowercase (a) for their menu selection. Also, it is important to let the user know if they entered an invalid choice.
Write a program that displays the following menu and prompts the user for a selection. Once the selection has been made, display the selection back to the user. Then, ask the user for two numbers and perform the selected operation (+, -, *, /). Display the results back to the user (e.g. 2 + 3 = 5). When dividing, display an error message if the second number is 0.
A) Add two numbers B) Subtract two numbers C) Multiply two numbers D) Divide two…
Write a c++ program that reads a list of enrollments from a file and prints a class roster for the teacher. Make the class roster lineup as neatly as you can and still fit on the screen.You can choose the actual values to use for your data. Make sure to do enough sets of data to well test your program!(Empty data set, normal data set, data with large values, data with short values, etc.)Also, your program can't know ahead of time how many people are enrolled in the class...Don't forget to read the file's name from the user and protect your program against any errors that may occur during theopening of the file.Try to use functions to break up the program into more manageable pieces.As an example, you might have the data file contain:# name# student number# address1# address2# phone number# majorJason James100400299400 Maple DrWestfalia, HI 66554555/555-1122Computer ScienceFaruk Ahmed1112223331200 West Jones AveSlimsville, PQ 22221332-4546Medeaval French PoetrySean…
In c++. The instructions are in the image. Please do not change existing code below just add to what is needed. I am very confused. Can you please show the input and output of the code it would help very much. There is also a text file which is named "input.txt" and it reads. Different solutions i have seen but i keep getting errors and errors i am still confused.
Movie 11Genre1Movie 22Genre2Movie 33Genre3Movie 44Genre4Movie 55Genre5
main.cpp
#include <iostream>#include <vector>#include <string>#include "functions.h"
int main(){vector<movie> movies; char option;
while (true){printMenu();cin >> option;cin.ignore();switch (option){case 'A':{string nm;int year;string genre;cout << "Movie Name: ";getline(cin, nm);cout << "Year: ";cin >> year;cout << "Genre: ";cin >> genre;//call you addMovie() herecout << "Added " << nm << " to the catalog" << endl;break;}case 'R':{ string mn;cout << "Movie…
Chapter 5 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 5.2 - Prob. 5.2.1CPCh. 5.2 - How many times are the following loop bodies...Ch. 5.2 - Prob. 5.2.3CPCh. 5.3 - What is wrong if guess is initialized to 0 in line...Ch. 5.4 - Revise the code using the System. nanoTime () to...Ch. 5.5 - Prob. 5.5.1CPCh. 5.6 - Prob. 5.6.1CPCh. 5.6 - What are the differences between a while loop and...Ch. 5.7 - Do the following two loops result in the same...Ch. 5.7 - What are the three parts of a for loop control?...
Ch. 5.7 - Suppose the input is 2 3 4 5 0. What is the output...Ch. 5.7 - What does the following statement do? for ( ; ; )...Ch. 5.7 - If a variable is declared in a for loop control,...Ch. 5.7 - Convert the following for loop statement to a...Ch. 5.7 - Count the number of iterations in the following...Ch. 5.8 - Can you convert a for loop to a while loop? List...Ch. 5.8 - Can you always convert a while loop into a for...Ch. 5.8 - Identify and fix the errors in the following code:...Ch. 5.8 - Prob. 5.8.4CPCh. 5.9 - How many times is the println statement executed?...Ch. 5.9 - Show the output of the following programs. (Hint:...Ch. 5.11 - Will the program work if n1 and n2 are replaced by...Ch. 5.11 - In Listing 5.11. why is it wrong if you change the...Ch. 5.11 - In Listing 5. 11, how many times the loop body is...Ch. 5.11 - Prob. 5.11.4CPCh. 5.11 - Prob. 5.11.5CPCh. 5.12 - What is the keyword break for? What is the keyword...Ch. 5.12 - The for loop on the left is converted into the...Ch. 5.12 - Rewrite the programs TestBreak and TestContinue in...Ch. 5.12 - After the break statement in (a) is executed in...Ch. 5.13 - What happens to the program if (low high) in line...Ch. 5.14 - Simply the code in lined 27-32 using a conditional...Ch. 5 - (Count positive and negative numbers and compute...Ch. 5 - (Repeat additions) Listing 5.4,...Ch. 5 - (Conversion from kilograms to pounds) Write a...Ch. 5 - (Conversion from miles to kilometers) Write a...Ch. 5 - (Conversion from kilograms to pounds and pounds to...Ch. 5 - Prob. 5.6PECh. 5 - (Financial application: compute future tuition)...Ch. 5 - (Find the highest score) Write a program that...Ch. 5 - (Find the two highest scores) Write a program that...Ch. 5 - (Find numbers divisible by 5 and 6) Write a...Ch. 5 - (Find numbers divisible by 5 or 6, but not both)...Ch. 5 - (Find the smallest n such that n2 12,000) Use a...Ch. 5 - (Find the largest n such that n3 12,000) Use a...Ch. 5 - (Compute the greatest common divisor) Another...Ch. 5 - (Display the ASCII character table) Write a...Ch. 5 - (Find the factors of an integer) Write a program...Ch. 5 - (Display pyramid) Write a program that prompts the...Ch. 5 - (Display four patterns using Loops) Use nested...Ch. 5 - (Display numbers in a pyramid pattern) Write a...Ch. 5 - (Display prime numbers between 2 and 1,000) Modify...Ch. 5 - Prob. 5.21PECh. 5 - For the formula to compute monthly payment, see...Ch. 5 - (Demonstrate cancellation errors) A cancellation...Ch. 5 - Prob. 5.24PECh. 5 - (Compute ) You can approximate by using the...Ch. 5 - (Compute e) You can approximate e using the...Ch. 5 - (Display leap years) Write a program that displays...Ch. 5 - (Display the first days of each month) Write a...Ch. 5 - (Display calendars) Write a program that prompts...Ch. 5 - (Financial application: compound value) Suppose...Ch. 5 - (Financial application: compute CD value) Suppose...Ch. 5 - (Game: lottery) Revise Listing 3.8, Lottery.java,...Ch. 5 - (Perfect number) A positive integer is called a...Ch. 5 - (Game: scissor; rock, paper) Programming Exercise...Ch. 5 - (Summation) Write a program to compute the...Ch. 5 - (Business application: checking ISBN) Use loops to...Ch. 5 - (Decimal to binary) Write a program that prompts...Ch. 5 - (Decimal to octal) Write a program that prompts...Ch. 5 - (Financial application: find the sales amount) You...Ch. 5 - (Simulation: heads or tails) Write a program that...Ch. 5 - (Occurrence of max numbers) Write a program that...Ch. 5 - (Financial application: find the sales amount)...Ch. 5 - (Math: combinations) Write a program that displays...Ch. 5 - (Computer architecture: bit-level operations) A...Ch. 5 - (Statistics: compute mean and standard deviation)...Ch. 5 - (Reverse a string) Write a program that prompts...Ch. 5 - (Business: check ISBN-13) ISBN -13 is a new...Ch. 5 - (Process string) Write a program that prompts the...Ch. 5 - (Count vowels and consonants) Assume that the...Ch. 5 - Prob. 5.50PECh. 5 - (Longest common prefix) Write a program that...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Repair Bill Suppose automobile repair customers are billed at the rate of per hour for labor. Also, suppose co...
Introduction To Programming Using Visual Basic (11th Edition)
What is the output of the following (when embedded in a complete program)? int n = 5; while (--n 0) { if (n ==...
Problem Solving with C++ (9th Edition)
Essay Class Design an Essay class that extends the GradedActivity class presented in this chapter. The Essay cl...
Starting Out with Java: Early Objects (6th Edition)
T F Constructors may have default arguments.
Starting Out with C++ from Control Structures to Objects (9th Edition)
What is a count-controlled loop?
Starting Out with Programming Logic and Design (4th Edition)
The following table represents the addresses and contents (using hexadecimal notation) of some cells in a machi...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Traceback (most recent call last): File "main.py", line 12, in <module> from Artist import Artist ModuleNotFoundError: No module named 'Artist'arrow_forwardWrite in C++ in 2 different programs/files. One will have the code for wzip and one will have the code for wzip. Description: wzip and wunzip class overview: The next tools you will build come in a pair, because one (wzip) is a file compression tool, and the other (wunzip) is a file decompression tool. The type of compression used here is a simple form of compression called run-length encoding (RLE). RLE is quite simple: when you encounter n characters of the same type in a row, the compression tool (wzip) will turn that into the number n and a single instance of the character. Thus, if we had a file with the following contents: aaaaaaaaaabbbb the tool would turn it (logically) into: 10a4b The exact format of the compressed file is quite important; here, you will write out a 4-byte integer in binary format followed by the single character in ASCII. Thus, a compressed file will consist of some number of 5-byte entries, each of which is comprised of a 4-byte integer (the…arrow_forwardI have seen some solutions to this problem in Bartleby's library that make no sense to me. I am learning C++, more specifically working with dynamic integers and have become confused with what has been provided previously by others. Using dynamic integers, can I get help with creating a class named 'largeIntegers' so that an object of this class can store an integer of any number of digits. If I could get help with setting up operations to add, subtract, multiply, and compare integers stored in two objects. Also, if someone could explain and help myself create constructors to properly initialize objects and functions to set, retrieve, and print the values of objects. There are three files I am working with: main.cpp, largeIntegers.h, and largeIntegers.cpp largeIntegers.cpp #include <iostream> using namespace std; largeIntegers.h //Specification file largeIntegers.h #ifndef H_largeIntegers #define H_largeIntegers #include <iostream> using namespace std;…arrow_forward
- I have seen some solutions to this problem in Bartleby's library that make no sense to me. I am learning C++, more specifically working with dynamic integers and have become confused with what has been provided previously by others. Using dynamic integers, can I get help with creating a class named 'largeIntegers' so that an object of this class can store an integer of any number of digits. If I could get help with setting up operations to add, subtract, multiply, and compare integers stored in two objects. Also, if someone could explain and help myself create constructors to properly initialize objects and functions to set, retrieve, and print the values of objects. There are three files I am working with: main.cpp, largeIntegers.h, and largeIntegers.cpp largeIntegers.cpp #include <iostream> using namespace std; largeIntegers.h //Specification file largeIntegers.h #ifndef H_largeIntegers #define H_largeIntegers #include <iostream> using namespace std;…arrow_forwardI opened a CSV file in C++ and the headings of the file are Name, Class, Subject, Standing (in same order). I want to output the file on the console in ascending order of Subject (later I will be performing insert sort). how do I make it in ascending order of Subject which is third column. please add code.arrow_forwardIn c++. The instructions are in the image. Please do not change existing code below just add to what is needed. I am very confused. Can you please show the input and output of the code it would help very much. There is also a text file which is named "input.txt" and it reads. Movie 11Genre1Movie 22Genre2Movie 33Genre3Movie 44Genre4Movie 55Genre5 main.cpp #include <iostream>#include <vector>#include <string>#include "functions.h" int main(){vector<movie> movies; char option; while (true){printMenu();cin >> option;cin.ignore();switch (option){case 'A':{string nm;int year;string genre;cout << "Movie Name: ";getline(cin, nm);cout << "Year: ";cin >> year;cout << "Genre: ";cin >> genre;//call you addMovie() herecout << "Added " << nm << " to the catalog" << endl;break;}case 'R':{ string mn;cout << "Movie Name:";getline(cin, mn);bool found;found = //call you removeMovie()here if (found == false)cout…arrow_forward
- I am having trouble writing a python program that opens a file that contains baby names. One file for boys and one for girls. The user inputs a name and the program searches the list to see if the name is in either file. I have the loop set and the program runs with no exception error but no matter what name is entered, the program does not find it.arrow_forwardAND MATCH OUTPUT WITH QUESTION OUTPUT AS IT IS. USE TEMPLATE PROVIDED AT END OF QUESTION WHILE MAKING SOLUTION -------------------------------------------------------- Write a C++ program to check for the not-eligible donor by throwing a custom exception.Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. The class Donor has the following protected variables. Data Type Variable string name int age int weight string bloodGroup In the Donor class, define the following function. Method Description bool validateDonor(Donor donor) This method validates donor eligibility. Validate the donor details with the following conditions. 1.Age must be greater than 30 then the donor is eligible. 2.If the age is less than 30 then throw an exception and check the weight should be greater than 44 kg in catch block, If the weight is…arrow_forwardThis assignment will give you a chance to perform some simple tasks with pointers. The tasks are only loosely related to each other. Start the assignment by copying the code below and pasting it into a .cpp file, then add statements to accomplish each of the tasks listed. Don't delete any of the given code or comments. Some of the tasks will only require a single C++ statement, others will require more than one. No documentation is required for this part of the assignment. /* Type your code after each of the commented instructions below (except that the statements for instructions 11 and 21 should be written where the instructions indicate). I have written the first statement for you. */ #include <iostream> using namespace std; int main() { // 1. Create two integer variables named x and y. int x; // 2. Create an int pointer named p1. // 3. Store the address of x in p1. // 4. Use only p1 (not x) to set the value of x to 99. // 5. Using cout and x (not p1), display the value of x.…arrow_forward
- Do not read directly from the example files, as the automated testing system expects you to read from the standard input. Instead, process the lines as follows: 3 - Geography Grades 3 Make a copy of your program for the problem Geography Grades 2 and change the code in such a way that your program can process multiple groups. These groups are on the input separated by ’=\n’. Every group starts with a first line that contains the name of the group and the lines after contain the information about the students in the same way as is specified for the problem Geography Grades 1. With the input 1bErik Eriksen__________4.3 4.9 6.7Frans Franssen________5.8 6.9 8.0=2bAnne Adema____________6.5 5.5 4.5Bea de Bruin__________6.7 7.2 7.7Chris Cohen___________6.8 7.8 7.3Dirk Dirksen__________1.0 5.0 7.7 The output should be: Report for group 1bErik Eriksen has a final grade of 6.0Frans Franssen has a final grade of 7.0End of reportReport for group 2bAnne Adema has a final grade of 6.0Bea de Bruin…arrow_forwardThis assignment will give you practice on basic C programming. You will implement a few Cprogramsarrow_forwardCan you write a new code in C ++ language with the values I sent you, just like this output? There are two files named group1.txt and group2.txt that contain course information and grades of each student for each class. I will calculate each course average for each group and show in simple bar graph. Use "*" and "#"characters for group1 and group2, respectively. I will see the number -999 at the end of each line in the input files. This value is used for line termination and you can use it to verify that you have arrived at the end of the line. The averages of each group should also be calculated and printed at the end of the file. All of the results will be printed to the file. There will be no screen output. Sample output is shown in Figure 1. Group 1: CSC 80 100 70 80 72 90 89 100 83 70 90 73 85 90 -999ENG 80 90 80 94 90 74 78 63 83 80 90 -999HIS 90 70 80 70 90 50 89 83 90 68 90 60 80 -999MTH 74 80 75 89 90 73 90 82 74 90 84 100 90 79 -999PHY 100 83 93 80 63 78 88…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Control Structures - while loop - do-while loop - for loop - Goto - break - continue statements; Author: EzEd Channel;https://www.youtube.com/watch?v=21l11_9Osd0;License: Standard YouTube License, CC-BY