Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 2.4, Problem 34STQ
Although it is kind of silly, state legislatures have been known to pass laws that “change” the value of pi. Suppose you live in a state where, by law, the value of pi is exactly 3.14. How must you change the
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
kindly change the program following the procedure on the problem. please list the changes you have made on the program t..thank you
Help Me With C Programming.
At Lili's birthday party, there is a game arranged by Jojo as the host. The game is handing out a number of Y candies to a number of X people where all the sweets taste sweet except for the last one candy that tastes like rotten beans. The distribution of sweets will be sequential starting from position Z and if it passes the last position then the distribution of candy continues to the first position. Write down the person in the position of who will get the last candy.
Format Input The first line of input is T, which is the number of test cases. The second row and the next number of T lines are X, Y, Z. X is the number of people who will be handed out candy. Y is the number of candies available. Z is the initial position of the person who will be handed out the candy. Format Output A string of "Case #N: " and a number that is the position of the person who got the last candy
[Look at Image]
In the sample above, for example, which is inputted in the…
You're interested in looking at trending Twitter hashtags, but you notice that people aren't very consistent with how they use them. Specifically, the capitalisation and punctuation in hashtags is inconsistent. You decide to write a program to read in tweets, normalise any hashtags present, and print out a tally of frequencies.
Hashtags should only include words starting with #. All punctuation should be removed from the end of a hashtag, and the letters should be converted to lowercase. For instance, #Python! should be normalised to #python, and #Today_I_Learned... should be #today_i_learned.
Your program should work like this. The tally of hashtags can be printed out in any order.
Tweet: #Python is #AWESOME!Tweet: This is #So_much_fun #awesomeTweet: #python 1#awesome 2#so_much_fun 1
Chapter 2 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Ch. 2.1 - Prob. 1STQCh. 2.1 - Can a Java program have two different variables...Ch. 2.1 - Prob. 3STQCh. 2.1 - Give the declaration for two variables of type...Ch. 2.1 - Write the declaration for two variables called...Ch. 2.1 - What is the normal spelling convention for named...Ch. 2.1 - Prob. 7STQCh. 2.1 - Prob. 8STQCh. 2.1 - Prob. 9STQCh. 2.1 - Prob. 10STQ
Ch. 2.1 - Prob. 11STQCh. 2.1 - In the Programming Tip entitled Type Casting a...Ch. 2.1 - What is the output produced by the following lines...Ch. 2.1 - What is the output produced by the following lines...Ch. 2.1 - Prob. 15STQCh. 2.1 - Prob. 16STQCh. 2.1 - Consider the following statement from the program...Ch. 2.1 - Prob. 18STQCh. 2.2 - Prob. 19STQCh. 2.2 - What output is produced by the following...Ch. 2.2 - What output is produced by the following...Ch. 2.2 - What output is produced by the following...Ch. 2.2 - What output is produced by the following...Ch. 2.2 - What output is produced by the following...Ch. 2.2 - What is the value of the expression sl.equals(s2)...Ch. 2.2 - What is the value of the expression s1.equals (s2)...Ch. 2.3 - Write Java statements that will cause the...Ch. 2.3 - What is the difference between the methods...Ch. 2.3 - Write a complete Java program that reads a line of...Ch. 2.3 - Write a complete Java program that reads one line...Ch. 2.3 - What output is produced by the following...Ch. 2.4 - Prob. 32STQCh. 2.4 - What is the output produced by the following Java...Ch. 2.4 - Although it is kind of silly, state legislatures...Ch. 2.5 - Prob. 35STQCh. 2.5 - Give a Java statement that will display a dialog...Ch. 2.5 - Give a Java statement that, when executed, will...Ch. 2.5 - Prob. 38STQCh. 2.5 - Write a complete Java program that produces a...Ch. 2.5 - Write a complete Java program that behaves as...Ch. 2 - Write a program that demonstrates the approximate...Ch. 2 - Write a program that demonstrates type casting of...Ch. 2 - Write a program that demonstrates the operator %...Ch. 2 - If u = 2, v = 3, w = 5, x = 7, and y = 11, what is...Ch. 2 - What changes to the ChangeMaker program in Listing...Ch. 2 - If the int variable x contains 10, what will the...Ch. 2 - Write some Java statements that use the String...Ch. 2 - Prob. 8ECh. 2 - Prob. 9ECh. 2 - Write a single Java statement that will display...Ch. 2 - What does the Java code Scanner keyboard = new...Ch. 2 - What does the Java code Scanner keyboard = new...Ch. 2 - Prob. 13ECh. 2 - Many sports have constants embedded in their...Ch. 2 - Prob. 15ECh. 2 - Define named constants that you could use in...Ch. 2 - Write a program that reads three whole numbers and...Ch. 2 - Write a program that uses Scanner to read two...Ch. 2 - Write a program that reads the amount of a monthly...Ch. 2 - Write a program that reads a four-digit integer,...Ch. 2 - Prob. 5PCh. 2 - Prob. 6PCh. 2 - Write a program that converts degrees from...Ch. 2 - Write a program that reads a line of text and then...Ch. 2 - Write a program that will read a line of text as...Ch. 2 - Write a program that asks the user to enter a...Ch. 2 - Write a program that determines the change to be...Ch. 2 - Write a program that reads a 4-bit binary number...Ch. 2 - Prob. 7PPCh. 2 - The Harris-Benedict equation estimates the number...Ch. 2 - Repeat any of the previous programming projects...Ch. 2 - Write a program that reads a string for a date in...Ch. 2 - It is important to consider the effect of thermal...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What type of object should an overloaded operator function return?
Starting Out with C++: Early Objects
The ____________ is always transparent.
Web Development and Design Foundations with HTML5 (8th Edition)
Explain how entities are transformed into tables.
Database Concepts (8th Edition)
For each of the following activities, give a PEAS description of the task environment and characterize it in te...
Artificial Intelligence: A Modern Approach
Assume that r1 and r2 are variables that reference Rectangl e objects, and the following statements are execute...
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
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
- C++ Create a Blackjack (21) game. Your version of the game will imagine only a SINGLE suit of cards, so 13 unique cards, {2,3,4,5,6,7,8,9,10,J,Q,K,A}. Upon starting, you will be given two cards from the set, non-repeating. Your program MUST then tell you the odds of receiving a beneficial card (that would put your value at 21 or less), and the odds of receiving a detrimental card (that would put your value over 21). Recall that the J, Q, and K cards are worth ‘10’ points, the A card can be worth either ‘1’ or ‘11’ points, and the other cards are worth their numerical values. FOR YOUR ASSIGNMENT: Provide two screenshots, one in which the game suggests it’s a good idea to get an extra card and the result, and one in which the game suggests it’s a bad idea to get an extra card, and the result of taking that extra card.arrow_forwardIN C++ This is a simulated chess game. With this project, I want you to move all the pieces on one side of the board. First: If you are unsure how the pieces of a chess board move, do some research. There is plenty of information out there to instruct how a chessboard functions. Your chess piece movement must follow the rules of the game. Second: This is a one-sided board and used to illustrate how each piece moves. Third: The program must keep track of the location of each piece. By this I mean that if a piece is moving, it must respect the position of the other pieces on the board. Fourth: With each move the user should also be given the option to start a new game or end the program.arrow_forwardWRITE A CODE IN C++ LANGUAGE To implement the multiplayer game with multiple players moving and collecting items concurrently, you can use the following steps: Step 1: Generate a random number between 10 - 99 and multiply it by the last digit of your roll number. Step 2: Divide your roll number with the generated number in step 1 and take the mod of the result with 25. Step 3: If the result in step 2 is less than 10, add 15 to it to get the board size. Step 4: Create an n x n board and initialize it with empty squares and randomly place items on some squares. Step 5: Create a thread for each player and pass the player's ID and starting position to the thread. Step 6: Each player thread should handle the player's movement and item collection. Step 7: When a player moves onto a square that contains an item, the player thread should send a message to the main thread indicating that the player has collected an item and the item's value. Step 8: The main thread should update the…arrow_forward
- Write a c++ program to assign passengers seats in an airplane. Assume a small airplane with seat numbering as follows: 1 A B C D 2 A B C D 3 A B C D 4 A B C D 5 A B C D 6 A B C D 7 A B C D The program should display the seat pattern, with an 'X' marking the seats already assigned. For example, after seats 1A, 2B, and 4C are taken, the display should look like this: 1 X B C D 2 A X C D 3 A B C D 4 A B X D 5 A B C D 6 A B C D 7 A B C D After displaying the seats available, the program prompts for the seat desired, the user types in a seat, and then the display of available seats is updated. This continues until all seats are filled or until the user signals that the program should end. If the user types in a seat that is already assigned, the program should say that that seat is occupied and ask…arrow_forwardHelp me homework c++ The shots file holds a list of shots (imagine some hitscan weapon in a video game like a shotgun or something). Each shot has an origin and a direction. The origin is an (x,y) coordinate, like (5,3). The direction is a slope and whether the shot is traveling along that slope or in the reverse. A slope of "Vertical" means that the shot is travellingstraight up and down. The format is:x_location y_location slope(either a number like 2.1 or a non-number meaning"Vertical") forwards(1 meaning forwards, 0 meaning backwards) 0 0 0 00 0 0 10 0 Vertical 00 0 Squirrel 110 10 -1 1-10.1 -100.01 2.1 0 The first line is a horizontal line shooting left from the origin (0,0).The second line is a shot also travelling horizontally from the origin, but forward along the x axis instead of backwards.The third line is shooting straight down out of the originThe fourth line is shooting straight up out of the origin (any non-number means Vertical, not just Vertical)The fifth line is…arrow_forwardProject in C language: PLEASE read the INSTRUCTIONS carefully: * The user who is playing this game will have a small visible deck with a total of 5 numbers or letters to choose to solve the puzzle on the board (which will have a few blank spaces for users to input their answers). Format: There should be six boxes (grid-like boxes) for each letter of the word. If you could just code for the word ("player") that would be great! For the output it should look like this: Puzzle #1: On Playing Board: “ p( )aye( )". Player's Playing Deck: "(r), (j), (t), (c), (l)" * When the letters are on the board it will be an incomplete word that needs to be filled out with the letters from their deck as well. Correct Word: “player” If they successfully guess the word "player" they will be awardedarrow_forward
- Can 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. Group 1: CSC 80 100 70 80 72 90 89 100 83 70 90 73 85 90 -999 ENG 80 90 80 94 90 74 78 63 83 80 90 -999 HIS 90 70 80 70 90 50 89 83 90 68 90 60 80 -999 MTH 74 80 75 89 90 73 90 82 74 90 84 100 90 79 -999 PHY 100 83 93 80 63 78 88 89 75 -999 Group 2: CSC 90 75 90 75 80 89 100 60 80 70 80 -999 ENG 80 80 70 68 70 78 80 90 90 76 -999 HIS 100 80 80 70 90 76 88 90…arrow_forwardC++ In this task, you are required to write a code that converts an Octal number into its equivalent Decimal value or vice versa. The user first selects the conversion choice by inserting 1 or 2. Choice 1 is followed by inserting an Octal integer and getting its Decimal equivalent value as an output. Choice 2 requires inserting a Decimal integer and prints out its Octal equivalent. The Octal numeral system, is the base-8 number system, and uses the digits 0 to 7, that is to say 10 octal represents 8 Decimal and 100 octal represents 64 Decimal. Convertion from an Octal integer into Decimal In the Decimal system, each number is the digit multiplied by 10 to the power of its location (starting from 0). For example: 74 decimal = 7 x 10^1 + 4 x 10^0 1252 decimal = 1 x 10^3 + 2 x 10^2 + 5 x 10^1 + 2 x 10^0 each number is the digit multiplied by 8 to the power of its location (starting from 0). For example: 112 octal = 1 x 8^2 + 1 x 8^1 + 2 x 8^0 Converting an Octal integer into…arrow_forwardC++ The restaurant owner wants to give those attending a specific dish, but the method yields a lot more food than what he can give. Because of this, the kitchen staff is interested in creating a meal with fewer ingredients but with identical ingredient ratios. Yet, the cook dislikes fractions. The cook desires that the decreased method also include just whole numbers of items since the earlier method only called for entire numbers. Assist the cook in deciding the quantity of each ingredient to use to produce the least amount of food. Input 3 244 3234 43 1596 Output 11 234 1532arrow_forward
- can you do it in python, thank you.arrow_forwardThis needs to be done in Java! (Sales Commission Calculator) A large company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5,000 worth of merchandise in a week receives $200 plus 9% of $5,000, or a total of $650. You’ve been supplied with a list of the items sold by each salesperson. The values of these items are shown below. Develop a Java application that inputs one salesperson’s items sold for last week and calculates and displays that salesperson’s earnings. There’s no limit to the number of items that can be sold. Item Value 1 239.99 2 129.75 3 99.95 4 350.89 Example Output: Enter number sold of product #1: 10Enter number sold of product #2: 20Enter number sold of product #3: 30Enter number sold of product #4: 40Earnings this week: $2182.61 NOTES: Do not create a separate class for this program. Create the…arrow_forwardIN C++ Only Jessie has a lot of cooking with her (N). He often remembered the first few letters of the recipe and forgot the others. Like all great chefs, Jessie re-calculated the recipes according to the priority. So, looking at the list of recipes and priorities answers Jessie's questions. Response from Jessie: Giving the first few letters of the recipe; you have to print the perfect recipe in the most important way. Note: Every recipe has a unique value. Please answer this in C++ Only Input 1 flour-with-eggs 100 1 G Output 0arrow_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
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY