Starting Out with C++ from Control Structures to Objects (9th Edition)
9th Edition
ISBN: 9780134498379
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 8, Problem 4PC
Charge Account Validation Modification
Modify the
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Java:
Part 1 & 2) Lottery Winners
Write a program that initializes an array with ten numbers (given below). Then let the
player enter his or her lottery number. The program should ask the user if he/she
wants to perform a linear search or binary search. (If the user chooses binary
search, using one of the sorting algorithms we learned in the class, sort the array).
Based on the searching algorithm payer chooses, it should print out the number of
searching comparisons performed and if it was a winning number.
int ticket[] = {85647, 62483, 13579, 26792, 52551, 33445,
79422, 76172, 93121, 26791 };\
Microsoft Visual Studio Debug Console
Enter your 5-digit lottery number: 12345
Press 1 to perform linear search, 2 for binary search: 1
Original values: 85647 62483 13579 26792 52551 33445 79422 76172 93121 26791
Number of comparisons made: 10
You did not win.
Microsoft Visual Studio Debug Console
Enter your 5-digit lottery number: 12345
Press 1 to perform linear search, 2 for binary search: 2…
Task 3: Statistics using arrays:
by java programming
With the spread of COVID 19, the HR department in a company has decided to conduct some statistics
among the employees in order to determine the number of infections according to some conditions.
For each employee, they have to record the code, name, age, whether he/she was infected or no and
the remaining days of leaves for him/her.
You are requested to write the program that maintains the lists of details for the employees as
mentioned above using the concept of arrays. The program repeats the display of a menu of services
until the user decides to exit.
1. Start by initializing the employee details by reading them from the keyboard.
2. Repeat the display of a menu of 4 services, perform the required task according to the user’s
choice and asks the user whether he/she wants to repeat or no. You need to choose one service
from each category (‘A’,’B’,’C’,’D’)
a. A. Display the total number of employees that were infected
b. B.…
Chapter 8 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Ch. 8.2 - Prob. 8.1CPCh. 8.2 - Prob. 8.2CPCh. 8.2 - Prob. 8.3CPCh. 8.2 - Prob. 8.4CPCh. 8 - Prob. 1RQECh. 8 - If a linear search function is searching for a...Ch. 8 - Prob. 3RQECh. 8 - A binary search function is searching for a value...Ch. 8 - What is the maximum number of comparisons that a...Ch. 8 - Prob. 6RQE
Ch. 8 - Why is the selection sort more efficient than the...Ch. 8 - Prob. 8RQECh. 8 - The __________ search algorithm repeatedly divides...Ch. 8 - Prob. 10RQECh. 8 - The ____________ search algorithm requires that...Ch. 8 - If an array is sorted in ______________ order, the...Ch. 8 - If an array is sorted in _____________ order, the...Ch. 8 - Prob. 14RQECh. 8 - Prob. 15RQECh. 8 - Prob. 16RQECh. 8 - T F The maximum number of comparisons performed by...Ch. 8 - Prob. 18RQECh. 8 - Charge Account Validation Write a program that...Ch. 8 - Lottery Winners A lottery ticket buyer purchases...Ch. 8 - Lottery Winners Modification Modify the program...Ch. 8 - Charge Account Validation Modification Modify the...Ch. 8 - Rainfall Statistics Modification Modify the...Ch. 8 - String Selection Sort Modify the selectionSort...Ch. 8 - Binary String Search Modify the binarySearch...Ch. 8 - Search Benchmarks Write a program that has an...Ch. 8 - Sorting Benchmarks Write a program that uses two...Ch. 8 - Sorting Orders Write a program that uses two...Ch. 8 - Using FilesString Selection Sort Modification...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Fill in the blanks in each of the following statements: A(n)and a(n)begin and end the body of every method.
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Indexing can clearly be very beneficial. Why should you not create an index for every column of every table of ...
Modern Database Management
What are some general properties of the consumable-electrode arc-welding processes?
Degarmo's Materials And Processes In Manufacturing
The current source in the circuit shown generates the current pulse
Find (a) v (0); (b) the instant of time gr...
Electric Circuits. (11th Edition)
Consider the following skeletal C program: void fun1(void); / prototype / void fun2(void); / prototype / void f...
Concepts Of Programming Languages
// Superclass public class Vehicle { private double cost; public Vehicle (double c) { cost = c; } (Other method...
Starting Out with Java: From Control Structures through Data Structures (4th 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
- True or FalseYou use the == operator to compare two array reference variables and determine whether the arrays are equal.arrow_forwardMovie Data Write a program that will be used to gather statistical data about the number of movies college students see in a month. The program should ask the user how many students were surveyed and dynamically allocate an array of that size. The program then should allow the user to enter the number of movies each student has seen. It should then sort the scores and calculate the average. Modularity: Main: The main function should accept the number of students from the user and dynamically create an array large enough to contain number of movies watched for each student. Input validation: The number of students should be a positive integer. Print the average and free the allocated array when complete. Get the data: This function should get the number of movies watched by each college student. Input validation: The number of movies should be a positive integer. Sort the data: This function should sort the array in ascending order. Note you may use the Standard Template Library sort…arrow_forwardWhat occurs when a selection sort is applied to an array?arrow_forward
- Reverse ArrayWrite a function that accepts an int array and the array’s size as arguments. The function should create a copy of the array, except that the element values should be reversedin the copy. The function should return a pointer to the new array. Demonstrate thefunction in a complete program.arrow_forwardLottery Winners Directions A lottery ticket buyer purchases 10 tickets a week, always playing the same 10 5-digit “lucky” combinations. Write a program that initializes an array or a vector with these numbers and then lets the player enter this week’s winning 5-digit number. The program should perform a linear search through the list of the player’s numbers and report whether or not one of the tickets is a winner this week. Here are the numbers: 13579, 26791, 26792, 33445, 55555, 62483, 77777, 79422, 85647, 93121 Validate the input for the week's winning number. Ensure the input does not crash when entering a character or string value. Make sure to accept only positive numbers. Ask the user for the correct value each time they enter an incorrect one.arrow_forwardQ: Integrate time function in insertion sort code and check time for 50,100 and 250 values Question: Inserting Sort #include<iostream>using namespace std;//swappingvoid swapping(int &a, int &b) { //variable declaration int temp;//swapping temp = a; a = b; b = temp;}//to display the arrayvoid display(int *array, int s) { //Loop for(int x = 0; x<s; x++) //Creating the array cout << array[x] << " "; cout << endl;}//Performing the selectionSortvoid selectionSort(int *array, int s) { //variable declaration int x, j, min; //loop for(x = 0; x<s-1; x++) { //used to minimum data min = x; for(j = x+1; j<s; j++) if(array[j] < array[min]) min = j; //placing the value swap(array[x], array[min]); }}//main of the codeint main() { //variable declaration int n; //input cout << "Enter the number of elements: "; //Storing the input cin >> n;…arrow_forward
- Finding the common members of two dynamic arrays: Write a program that first reads two arrays and then finds their common members (intersection). The program should first read an integer for the size of the array and then should create the two arrays dynamically (using new) and should read the numbers into array1 and array2 and then should find the common members and show it. Note: The list of the common members should be unique. That is no member should be listed more than once. Tip: A simple for loop is needed on one of the arrays (like array1) and one inner for loop for on array2. Then for each member of array1, if we find any matching member in array2, we record it. Sample run: Enter the number of elements of array 1: 7 Enter the elements of array 1: 10 12 13 10 14 15 12 Enter the number of elements of array 2: 5 Enter the elements of array 2: 17 12 10 19 12 The common members of array1 and array2 are: 12 10arrow_forwardPROGRAMMING LANGUAGE: C++ Write a program that accepts up to 20 test-match scores of a batsman in the range of 0 to 100 from the user and stores them in an array. Then main should report how many perfect scores (i.e., scores of 100) and ducks (i.e., scores of 0) were enteredarrow_forwardTrue or False. A simple variable, also called a scalar variable, is one that is unrelated to any other variable in the computer’s internal memory. The bubble sort algorithm gets its name from the fact that as the larger values drop to the bottom of the array, the smaller values rise, like bubbles, to the top. Programmers use arrays to temporarily store related data in the internal memory of the computer. Different variables in the same array may have different data types. The elements in an array can be used just like any other variables. When an array is sorted in ascending order, the first element contains the largest value and the last element contains the smallest value. When passing an array by reference in C++, you do not include the address-of operator before the formal parameter’s name in the function header. You distinguish one variable in a one-dimensional array from another variable in the same array using a unique integer,…arrow_forward
- Comprog Any loop statement can be used to traverse an array.arrow_forwardAn array definition reserves space for the array. true or falsearrow_forwardMatrix Multiplication• Write a multiplication function that accepts two 2D numpy arrays,and returns the product of the two. This function should test that thearrays are compatible (recall that the number of columns in the firstmatrix must equal the number of rows in the second matrix). Thisfunction should test the array sizes before attempting themultiplication. If the arrays are not compatible, the function shouldreturn -1. solve in pythonarrow_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 Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License