Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134521176
Author: SAVITCH
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 13, Problem 6PP
Program Plan Intro
Creation of
Program Plan:
- Define a structure “Node” and member variable as well as link to next node.
- Define a main method
- Define node instances for current and head nodes.
- Get count of suitors from user and store it in variable.
- If there is only one suitor, then that is the winner.
- If there is more than one suitor, create new node and assign values.
- Eliminate each suitor and delete element.
- Loop until the elements become same.
- Display the result of the operation.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program in Java that creates a login name for a user, given the user's first name, last name, and a four-digit integer as input. Output the login name, which is made up of the first six letters of the first name, followed by the first letter of the last name, an underscore (_), and then the last digit of the number (use the % operator). If the first name has less than six letters, then use all letters of the first name.
Ex: If the input is:
Michael Jordan 1991
the output is:
Your login name: MichaeJ_1
Ex: If the input is:
Nicole Smith 2024
the output is:
Your login name: NicoleS_4
In python Programming,
Suppose you have four dogs named Leo, Tom, Jerry, and Jack, and four dog food bowls labeled 1, 2, 3, and 4. Each bowl can hold up to sixteen scoops of food and each dog chooses a separate bowl, but it doesn't matter which dog uses which bowl. For their dinner each day, you distribute sixteen scoops of dog food into the bowls, so each bowl will receive a whole number units of food. You are pretty careless, and you sometimes leave some bowls empty. If you always put out the full sixteen units of food each day, how many ways can you distribute the food among the four bowls?
In Java -
A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are:
1) The year must be divisible by 4
2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400; therefore, both 1700 and 1800 are not leap years
Some example leap years are 1600, 1712, and 2016.
Write a program that takes in a year and determines whether that year is a leap year.
Default code:
import java.util.Scanner;
public class LabProgram { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int inputYear; boolean isLeapYear; isLeapYear = false; inputYear = scnr.nextInt(); /* Type your code here. */ }}
Chapter 13 Solutions
Problem Solving with C++ (10th Edition)
Ch. 13.1 - Suppose your program contains the following type...Ch. 13.1 - Suppose that your program contains the type...Ch. 13.1 - Prob. 3STECh. 13.1 - Prob. 4STECh. 13.1 - Prob. 5STECh. 13.1 - Prob. 6STECh. 13.1 - Prob. 7STECh. 13.1 - Suppose your program contains type definitions and...Ch. 13.1 - Prob. 9STECh. 13.2 - Prob. 10STE
Ch. 13.2 - Prob. 11STECh. 13.2 - Prob. 12STECh. 13.2 - Prob. 13STECh. 13 - The following program creates a linked list with...Ch. 13 - Re-do Practice Program 1, but instead of a struct,...Ch. 13 - Write a void function that takes a linked list of...Ch. 13 - Write a function called mergeLists that takes two...Ch. 13 - In this project you will redo Programming Project...Ch. 13 - A harder version of Programming Project 4 would be...Ch. 13 - Prob. 6PPCh. 13 - Prob. 8PPCh. 13 - Prob. 9PPCh. 13 - Prob. 10PP
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
- This is a JAVA programming assignment. Program a GeneticAlgorithm to find an integer number between 0 and 31 that maximizes the function f (x) = x2.The initial procedure is given as below.• Population size: 6• Crossover probability: 100%• Mutation probability: 5%• Terminating criteria:o When your program produces an average of candidates is equal to or greater than29, then you can accept it as a terminating condition.• Fitness function:o You can use the function itself (f (x) = x2)as your fitness function.1. For the 1st generation, you need to print the process and result of selection, crossover, andmutation operation.you need to print the corresponding integer values and bits (binary values)of selection, crossover, and mutation operation. You also need to decide andprint the crossover point and the mutation point.2. From the 2nd generation, you do not have to print all results of selection, crossover,mutation operations. You can just print the result of each generation. Please provide…arrow_forwardWrite a c++ program for a bank in your town that updates its customers’ accounts at the end of each month. The bank offers two types of accounts:savings and cheque. Every customer must maintain a minimum balance.Minimum balances for the accounts are: Savings : R 1000.00 Cheque: R 1500.00If a customer’s balance falls below the minimum balance, there is a service charge of R50.00 for savings accounts andR100.00 for cheque accounts. If the balance at the end of the month is at least the minimum balance, the clientreceives interest as follows: Savings accounts receive 4% interest on the balance. Cheque accounts with balances of up to R 5000.00 more than the minimum balance receive 3% interest;otherwise, accounts with balances more than R 5000.00 more than the minimum balance receive 5% interest.Write a c++ program that requests the user to enter a customer’s account number (int type), account type (char type - S for savings, C for checking) and current balance. The updated balance must…arrow_forwardWrite a program that deals a number of cards (their numerical values) to a player's hand. To begin, the program asks the player for the values of the deck of cards. Then, the program deals the first two cards of the deck to a player's hand, and asks him if he wants another card. If he does not want a card, the program ends. If he wants a card, the program deals the next available card in the deck, adds it to the player's hand, and asks the player if he wants another card. The dealing process repeats as long as the user continues to accept cards, or until the cards in the deck run out. Card dealing involves copying the available card from the deck vector to another vector, which stores the player's hand, at the next available position. Assume that the deck of cards consists of only 10 cards with numerical values from 1 to 10, which the player will enter by keyboard before the program deals. The following functions must be implemented/used: enterDeckValues. - This…arrow_forward
- This is an exercise to design and write a Python program in good programming style for a simulation of stock price over a period of 100 days. In this exercise, you are asked to simulate the stock price starting at $100.00 for 100 days with a daily fluctuation based on the Normal Distribution with mean = 0.0 & sigma = 0.0125. The program will show the daily stock price, the 7-day minimum, the 7-day maximum, the 7-day average, and the 50-day average. The program should also give an indication of "***" when the stock price drops beyond the 50-day average!arrow_forwardSolve in Python: Write a program that creates a login name for a user, given the user's first name, last name, and a four-digit integer as input. Output the login name, which is made up of the first five letters of the last name, followed by the first letter of the first name, and then the last two digits of the number (use the % operator). If the last name has less than five letters, then use all letters of the last name. Ex: If the input is: Michael Jordan 1991 the output is: Your login name: JordaM91 Ex: If the input is: Kanye West 2024 the output is: Your login name: WestK24arrow_forwardWRITE CODE IN C LANGUANGE On their way down the river, Jojo and Lili saw two frogs each in position X1 and X2. The two frogs are seen jumping happily towards the same direction that is come to Jojo. After watching the two frogs, Joio and Lili saw that the speed the two frogs are different. The first frog to start jumping from position X1 has a speed of v1, while the second frog that starts to jump from position X2 has a speed of V2. Joig guess that "YES" both frogs will be in the same position in a certain time T, while Bibi guessing "NO" the two frogs will never be in the same position in time. Help Joio and Lili calculate the frog's movements to determine whether the guess they are rightarrow_forward
- Write a program in C++ that reads HAND_SIZE cards from the user, then analyzes the cards and prints out the type of poker hand that they represent. (HAND_SIZE will be a global constant, typically 5, but your program must still work if it is set to something other than 5.) Poker hands are categorized according to the following hand-types: Straight flush, four of a kind, full house, straight, flush, three of a kind, two pairs, pair, high card. To simplify the program we will ignore card suits, and face cards. The values that the user inputs will be integer values from LOWEST_NUM to HIGHEST_NUM. (These will be global constants. We'll use LOWEST_NUM = 2 and HIGHEST_NUM = 9, but your program must work if these are set to something different.) When your program runs it should start by collecting HAND_SIZE integer values from the user and placing the integers into an array that has HAND_SIZE elements. It might look like this: Enter 5 numeric cards, no face cards. Use 2 - 9. Card 1: 8 Card 2:…arrow_forwardin python. Given the following list of student test scores, apply a class "curve" to each score. The class curve is as follows: 90 or above: no curve 80 to 90: +2 points 70 to 80: +5 points Lower than 70: +8 points Use the below test scores list: grades = [93, 74, 66, 98, 34, 75, 79, 83, 84, 91, 12, 69, 72] Pseudo code: for each score in list, If grade is greater than or equal to 90, move on to next score. Else if score is greater or equal to 80 but less than 90, add 2 points. Else if score is greater or equal to 70 but less than 80, add 5 points. Else, add 8 points Print out the new grades.arrow_forwardn an ancient land, the beautiful princess Eve (or handsome prince Val) had many suitors. Being royalty, it was decided that a special process must be used to determine which suitor would win the hand of the prince/princess. First, all of the suitors would be lined up one after the other and assigned numbers. The first suitor would be number 1, the second number 2, and so on up to the last suitor, number n. Starting at 4 the suitor in the first position, she/he would then count three suitors down the line (because of the three letters in his/her name) and that suitor would be eliminated and removed from the line. The prince/princess would then continue, counting three more suitors, and eliminate every third suitor. When the end of the line is reached, counting would continue from the beginning. For example, if there were 6 suitors, the elimination process would proceed as follows: 123456 initial list of suitors, starting count from 1 12456 suitor 3 eliminated,…arrow_forward
- vvvHarry has a big wall clock, that got hit while he was playing. Now, the minute hand doesn't rotate by the angle 2π/3600 each second, but now it moves according to different angle x. You can assume that coordinates of the centre of the clock are (0, 0) and the length of the minute hand is l. One endpoint of the minute hand is always located at the clock centre; the other endpoint is initially located at the point (0, l). One second later, Harry observes that this endpoint is at distance d above the x-axis, i.e., the y-coordinate of this endpoint is equal to d. Harry is curious about where the minute hand will be (specifically, its y-coordinate) after t seconds. Because t can be very large, Harry can't wait for that moment. Please help him to write a python code that prints a single line containing the output.Input: 4 2 2Output4Harry has a big wall clock, that got hit while he was playing. Now, the minute hand doesn't rotate by the angle 2π/3600 each second, but now it moves according…arrow_forwardJava Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 10 as long as the value is less than or equal to the second integer. For coding simplicity, output a space after every integer, including the last. Ex: If the input is: -15 30 the output is: -15 -5 5 15 25 Ex: If the second integer is less than the first as in: 20 5 the output is: Second integer can't be less than the first.arrow_forwardIn python In a hotel, there are a number of guests and cleaning staff. There is a conference room where guests can enter to have a party. Rules of using the room The guests and cleaning staff will be processes in your assignment. If someone from the cleaning staff is in the room cleaning, no guest can enter the room. Only one person from the cleaning staff can be in the room at a time. If guests are in the room, the cleaning staff will wait until the room is empty before entering. If the room is empty or other guests are in the room, guests can enter the room. You can have multiple guests in the room at the same time. The first guest to enter the empty room, will turn on the lights. The last guest to leave the room, will turn of the lights. (This is not the first guest in most cases) Guests can enter and leave the room at anytime as long as the room is empty or contains other guests. It is not uncommon for guests to enter the room, leave and then enter the room again while the party…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 Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning