Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
4th Edition
ISBN: 9780134787961
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 2.2, Problem 2.9CP
On paper, write a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
In Python, Assuming minors are younger than 13 and adults are older than 19, write a program that prompts the user to enter his/her age and then reports whether the user is a minor, teenager, or adult.
Start each program with your name and ID# in a comment.
Plan each program by writing pseudocode. Write all of your pseudocode as comments immediately after your name and SPC ID#.
Add more comments as needed in each program to explain your code.
Choose descriptive variable names in all programs.
Currency format. There should be no space between the $ sign and the first digit. See sep on page 66 to cancel the space automatically added when print items are separated by commas. Display commas as needed for values over $1,000.
Homework
1. Write a program to have the user guess a number stored in the program. If he
guesses right, tell him so. If he guesses wrong also tell him.
2. Write a program with a user interface which allows the user to enter 2
integers. It should then give him the option of adding them, subtracting them,
multiplying them or dividing them. It should then print the result.
3. Write a program with a user interface to allow a user to enter a number and to
tell him whether the number is even or odd. Use the truncating property of int
to do this.
4. Write a program with a user interface which allows the user to enter two
numbers. Check if the first number is a multiple of the second number. If it is
tell the user; if it isn't tell him also.
5. Write a program in which the user inputs a letter and you print it back
If the letter is already
t it cap
again for him.
6. Same a previous question, only this time if it is capital, print it lowercase.
7. Let the user enter 3 numbers. Print the numbers…
IN PYTHON ONLY: Write a program that uses radio buttons to select background colors for text, as shown in Figure 9.34. The available colors are red, yellow, white, gray, and green. The program uses the buttons <= and => to move the text left or right. The <= and => buttons move the message on the panel, and you can also set the background color for the message.
Chapter 2 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Ch. 2.1 - Prob. 2.1CPCh. 2.1 - When the program in Question 2.1 is saved to a...Ch. 2.1 - Complete the following program skeleton so it...Ch. 2.1 - On paper, write a program that will display your...Ch. 2.1 - Prob. 2.5CPCh. 2.1 - Every Java application program must have...Ch. 2.2 - The following program will not compile because the...Ch. 2.2 - Study the following program and show what it will...Ch. 2.2 - On paper, write a program that will display your...Ch. 2.3 - Examine the following program. // This program...
Ch. 2.3 - What will the following program display on the...Ch. 2.4 - Which of the following are illegal variable names...Ch. 2.4 - Prob. 2.13CPCh. 2.4 - Prob. 2.14CPCh. 2.4 - Prob. 2.15CPCh. 2.4 - A program declares a float variable named number,...Ch. 2.4 - Prob. 2.17CPCh. 2.4 - Prob. 2.18CPCh. 2.4 - Prob. 2.19CPCh. 2.4 - Prob. 2.20CPCh. 2.4 - What is wrong with the following statement? char...Ch. 2.5 - Prob. 2.22CPCh. 2.5 - Prob. 2.23CPCh. 2.6 - Write statements using combined assignment...Ch. 2.7 - The following declaration appears in a program:...Ch. 2.7 - The variable a is a float and the variable b is a...Ch. 2.9 - Write a statement that declares a String variable...Ch. 2.9 - Assume that stringLength is an int variable. Write...Ch. 2.9 - Prob. 2.29CPCh. 2.9 - Prob. 2.30CPCh. 2.9 - Prob. 2.31CPCh. 2.11 - Prob. 2.32CPCh. 2.11 - How are documentation comments different from...Ch. 2.14 - Prob. 2.34CPCh. 2.14 - Write code that will display each of the dialog...Ch. 2.14 - Write code that displays an input dialog asking...Ch. 2.14 - Prob. 2.37CPCh. 2 - Every complete statement ends with a __________....Ch. 2 - The following data 72 'A' Hello World 2.8712 are...Ch. 2 - A group of statements, such as the contents of a...Ch. 2 - Which of the following are not valid assignment...Ch. 2 - Which of the following are nor valid println...Ch. 2 - The negation operator is __________. a. unary b....Ch. 2 - This key word is used to declare a named constant....Ch. 2 - These characters mark the beginning of a...Ch. 2 - These characters mark the beginning of a...Ch. 2 - These characters mark the beginning of a...Ch. 2 - Which Scanner class method would you use to read a...Ch. 2 - Which Scanner class method would you use to read a...Ch. 2 - You can use this class to display dialog boxes. a....Ch. 2 - Prob. 14MCCh. 2 - Prob. 15MCCh. 2 - True or False: A left brace in a Java program is...Ch. 2 - True or False: A variable must be declared before...Ch. 2 - True or False: Variable names may begin with a...Ch. 2 - True or False: You cannot change the value of a...Ch. 2 - True or False: Comments that begin with / / can be...Ch. 2 - True or False: If one of an operators operands is...Ch. 2 - What will the following code segments print on the...Ch. 2 - int x = 0, y=2; x = y 4; System.out.println(x +...Ch. 2 - System.out.print(I am the incredible);...Ch. 2 - System.out.print(Be careful\n);...Ch. 2 - int a, x = 23; a = x % 2; System.out.println(x +...Ch. 2 - Find the Error There are a number of syntax errors...Ch. 2 - Show how the double variables temp, weight, and...Ch. 2 - Prob. 2AWCh. 2 - Write assignment statements that perform the...Ch. 2 - Assume the variables result, w, x, y, and z are...Ch. 2 - Prob. 5AWCh. 2 - Modify the following program so it prints two...Ch. 2 - What will the following code output? int apples =...Ch. 2 - What will the following code output? double d =...Ch. 2 - What will the following code output? String...Ch. 2 - What will the following code output? String...Ch. 2 - Convert the following pseudocode to Java code. Be...Ch. 2 - Prob. 12AWCh. 2 - Write the code to set up all the necessary objects...Ch. 2 - Prob. 14AWCh. 2 - A program has a float variable named total and a...Ch. 2 - Is the following comment a single-line style...Ch. 2 - Is the following comment a single-line style...Ch. 2 - Describe what the phrase self-documenting program...Ch. 2 - Prob. 4SACh. 2 - Prob. 5SACh. 2 - Prob. 6SACh. 2 - Prob. 7SACh. 2 - Prob. 8SACh. 2 - Briefly describe the difference between variable...Ch. 2 - What is the difference between comments that start...Ch. 2 - Briefly describe what programming style means. Why...Ch. 2 - Assume that a program uses the named constant PI...Ch. 2 - Assume the file Sales Average, java is a Java...Ch. 2 - Prob. 14SACh. 2 - Name, Age, and Annual Income Write a program that...Ch. 2 - Name and Initials Write a program that has the...Ch. 2 - Personal Information Write a program that displays...Ch. 2 - Star Pattern Write a program that displays the...Ch. 2 - Sales Prediction The East Coast sales division of...Ch. 2 - Land Calculation One acre of land is equivalent to...Ch. 2 - Sales Tax Write a program that will ask the user...Ch. 2 - Cookie Calories A bag of cookies holds 40 cookies....Ch. 2 - Miles-per-Gallon A cars miles-per-gallon (MPG) can...Ch. 2 - Test Average Write a program that asks the user to...Ch. 2 - Circuit Board Profit An electronics company sells...Ch. 2 - Prob. 12PCCh. 2 - Restaurant Bill Write a program that computes the...Ch. 2 - Male and Female Percentages Write a program that...Ch. 2 - Stock Commission Kathryn bought 600 shares of...Ch. 2 - Energy Drink Consumption A soft drink company...Ch. 2 - Ingredient Adjuster A cookie recipe calls for the...Ch. 2 - Word Game Write a program that plays a word game...Ch. 2 - Stock Transaction Program Last month Joe purchased...Ch. 2 - Planting Grapevines A vineyard owner is planting...Ch. 2 - Compound Interest When a bank account pays...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Give an example of each of the following, other than those described in this chapter, and clearly explain why y...
Modern Database Management
What is the highest decimal number that can be represented by each of the following numbers of binary digits (b...
Digital Fundamentals (11th Edition)
Running the Race Write a program that asks for the names of three runners and the time, in minutes, it took eac...
Starting Out with Java: Early Objects (6th Edition)
HTML Table of Names and Scores Write a class whose constructor takes a vector of Student objects, where each St...
Starting Out with C++: Early Objects
What is control break logic?
Starting Out with Programming Logic and Design (5th 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
- The Fibonacci series is a series that begins with 0 and 1 and has the property that each succeeding term is the sum of the two preceding terms. For example, the third Fibonacci number is 1 which is sum of 0 and 1. The next is 2, which is a sum of 1 + 1. Write a program that displays the first ten numbers in a Fibonacci series.arrow_forwardWrite a program that displays, ten per line, all the leap years in the twenty-first century (from year 2001 to 2100). The years are separated by exactly one space.arrow_forwardAny help with this first problem would be really helpful! Thank you so much!! Please display a screenshot of the code so I see the correct format and learn the proper way. Thank you!! 1. Write the following exercise using Java code. Add comments in each program to explain what your code is doing. Write a program that generates a two-column table showing Fahrenheit temperatures from -40F to 120F and their equivalent Celsius temperatures. Each line in the table should be 5 degrees F more than the previous one. Both the Fahrenheit and Celsius temperatures should be accurate to 1 decimal place.arrow_forward
- Write a program that promotes the user to enter the number of students and each student's name and score ,and finally displays the student with the highest score and the second highest score.arrow_forwardWrite a program that takes your full name as input and displays the abbreviations ofthe first and middle names except the last name which is displayed as it is. For example, if your name is Robert Brett Roser, then the output should be R.B.Roser.arrow_forwardjava Write a program that prompts the user to enter a point (x, y) and checks whether the point is within the rectangle centered at (0, 0) with width 10 and height 5. For example, (2, 2) is inside the rectangle and (6, 4) is outside the rectangle, as shown in the Figure. (Hint: A point is in the rectangle if its horizontal distance to (0, 0) is less than or equal to 10 / 2 and its vertical distance to (0, 0) is less than or equal to 5 / 2.) Here are sample runs of the program: Sample 1: Enter a point with two coordinates: 2 2 Point (2.0, 2.0) is in the rectangle Sample 2: Enter a point with two coordinates: 6 4 Point (6.0, 4.0) is not in the rectangle Analysis: (Describe the problem including input and output in your own words.) Design: (Describe the major steps for solving the problem.) Coding: (Go over your code step by step) Testing: (Describe how you test this program). In other words run your code with sample outputs.arrow_forward
- Please create a python code that meets the requirements of the attached image. I have previously submitted this but the code was a bit too complex for a beginner-level high school freshman. Your help is truly appreciated. Thank you!arrow_forwardWrite a program that prompts the user to enter apoint (x, y) and checks whether the point is within the rectangle centred at (1, 1)with width 10 and height 5. For example, (2, 2) is inside the rectangle and (6, 4)is outside the rectangle, as shown in Figure . (Hint: A point is in the rectangleif its horizontal distance to (0, 0) is less than or equal to 10 / 2 and its verticaldistance to (0, 0) is less than or equal to 5.0 / 2. Test your program to cover allcases.) Here are two sample runs. Enter a point with two coordinates: 2 2 ↵EnterPoint (2.0, 2.0) is in the rectanglearrow_forwardCreate a program that allows the user to enter a person's age (in years) and current salary. Both Next, you plan the algorithm and then desk-check it. Figure 8-15 shows the completed IPO algorithm contains two loops. The outer loop keeps track of the three annual raise rates (3%, 4%, chart and desk-check table, which (for simplicity) uses an age of 62 and a salary of $25000. The before retirement at age 65, using annual raise rates of 3%, 4%, and 5%. To calculate then for the input. In this case, the program should display a person's total earnings in Figure 8-15. You begin by analyzing the problem, looking first for the output and In this lab, you will plan and create an algorithm for the problem specification shown Frepure 8-15 Problem specification, IPO chart, and desk-check table for the retirement algorithm (continues) and 5%). The nested loop keeps track of the number of years until retirement. the amounts, the program will need to know the person's age and current salary. The…arrow_forward
- Create a program where a user guesses whether the value of the sum of two dice will be even or odd. The game will stop when the number of turns has reached 5. To guess odd, the user enters 1. To guess even, the user enters 2. After each roll, the program should display the two numbers rolled,the sum of the numbers, the user's guess as "Even" or "Odd" and whether they won or lost. Once the player ends the game, the program should display the number of times played and the number of turns won and lost and the number of times the dice were even/odd. Technical Requirements: Must use the random function for each die Use a loop to play the game for 5 turns Use an array to track each roll as to whether it was even or oddarrow_forwardWrite a python program that draws a rectangle filled with random colors horizontally. Let the user enter the side and width of the rectangle (hint: use a random number generator to set the pen rgb color value).arrow_forwardBased on the image attached, write the pseudo code (Language: C Code).arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
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