Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
7th Edition
ISBN: 9780134802213
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 2, Problem 10SA
What is the difference between comments that start with the // characters and comments that start with the /* characters?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
1#
Write a program that allows users to choose from one of three shapes: Squares, Circles or (right)
Triangles. Allow the user to use the first letter of the shape (S, C, T) to specify what they want. After the
shape is selected, ask the user for the appropriate data to calculate the shape's area, and then and print
that area value to the screen for them.
Area formulas you can use:
Triangle: % base x height
Square: length x length
Circle: % Pl x radius?
Notes:
The floating-point data type will be your friend here. Round your area answer so that no more
than 2 decimal places are shown when printing on the screen.
You can use 3.1415 for Pl; Think about this as a CONSTANT in your code.
For this part and especially part (b) below, think about componentizing your code. So one
gigantic main() is not a best practice and not what we want to see here. Remember what we
discussed about "procedural decomposition" and functions last week!
Name:
Claz
4. Directions: The question or incomplete statement below is followed by four suggested answers or
completions. Select the one that is best in each case.
The code segment below is intended to display all multiples of 5 between the values start and end, inclusive.
For example, if start has the value 35 and end has the value 50, the code segment should display the values
35, 40, 45, and 50. Assume that start and end are multiples of 5 and that start is less than end.
Line 1: i + start
Line 2: REPEAT TIMES
Line 3: {
DISPLAY (i)oplev a bonin vimobn ldemyA
i + i + 5
Line 4:
Line 5:
Line 6: }
Which of the following could replace in line 2 so that the code segment works
as intended?
wlf
a0wollo 1
end - start + 1
b. end start + 6
(( end - start) / 5) + 1
d. 5 * (end - start) + 1
а.
C.
Python please:
If the score is between 90 and 100, the grade is A, and the teacher comment is
'Exceptional work' for 100 only
'Excellent work' for anything other than 100
If the score is between 80 and 89, the grade is B, and the teacher comment is
'Very Good, can do better'
If the score is between 70 and 79, the grade is C, and the teacher comment is
'Good, but need to work harder'
If the score is between 60 and 69, the grade is D, and there are no teacher comments.
If the score is below 60, the grade is F, and the teacher comment is
'Fail, need to appear for a retest'
For example if the input (student test score) is
100
the output is
The Student grade is A and the teacher comment is 'Exceptional work'
Chapter 2 Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Ch. 2.1 - The following program will not compile because the...Ch. 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 - What does a variable declaration tell the Java...Ch. 2 - Prob. 7SACh. 2 - What things must be considered when deciding on a...Ch. 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
You developed Program 4.9 to reverse the digits of an integer typed in from the terminal However, this program ...
Programming in C
Modify Problem and Exercise 6-60 so that the list includes the number of products each customer bought in each ...
Modern Database Management (12th Edition)
Write for statements that print the following sequences of values: 1, 2, 3, 4, 5, 6, 7 3, 8, 13, 18, 23 20, 14,...
C How to Program (8th Edition)
Pet Class The Pet class Write a class named Pet, which should have the following data attributes: _ _ name (fo...
Starting Out with Python (4th Edition)
_____ is a special built-in pointer that is automatically passed as a hidden argument to all nonstatic member f...
Starting Out with C++: Early Objects
What type of event do menu items generate when selected by the user?
Starting Out with Java: Early Objects (6th 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
- ## Q4. Roman numeral converter Write a program that asks the user to enter a number within the range of 1 through 9. Use a switch statement to display the Roman numeral version of that number. *Hint 1: Verify the input is within the range between 1 and 9 before conversion." *Hint 2: Check this website for (Roman numeral|(https://en.wikipedia.org/wiki/Roman_numerals).* A4. Put your code here.arrow_forward,arrow_forwardPlease Use Visual Studio and C# ALPHABETIC TELEPHONE NUMBER TRANSLATOR Many companies use telephone numbers like 555-GET-FOOD so the number is easier for their customers to remember. On a standard telephone, the alphabetic letters are mapped to numbers in the following fashion: A, B, and C = 2 D, E, and F = 3 G, H, and I = 4 J, K, and L = 5 M, N, and O = 6 P, Q, R, and S = 7 T, U, and V = 8 W, X, Y, and Z = 9 Create an application that lets the user enter a 10-character telephone number in the format XXX-XXX-XXXX. The application should display the telephone number with any alphabetic characters that appeared in the original translated to their numeric equivalent. For example, if the user enters 555-GET-FOOD, the application should display 555-438-3663.arrow_forward
- 4. Area of a Rectangle • Write a program that compares the area of two rectangles. You can do this several ways. one way is to add the length and width of each rectangle to get it's area and then compare the two areas together. • The program should ask for the length and width of two rectangles and then tell the user which rectangle has the greater area, or if the areas are the same. • The area of a rectangle is the rectangle's length times its width. Name the source code file yourName HW4.py. • Test and run the program. Capture the output console and save it as an image file named yourName HW4 output.jpg. • Submit the py and the image files through Canvas. Note: Sample output below: Fast l: Code-Tracing Output in comenta Vart 21 Days of the Weekarrow_forwardJAVAarrow_forwardUrgentarrow_forward
- In C++ with comments please Modify the program 12-7 from page 826 as follows: 1. Add a third C-string as name3[NAME_LENGHT]. 2. Add a pair of cout/cin.getline() for the third string similar to the ones for first and second strings. 3. Add the appropriate case to the "if/else if" structure such that the three strings will be displayed in alphabetical order. Hint: There are 6 possible cases (3!, 3 factorial = 3*2*1 = 6) for all complete permutations. The easiest check is to input the three strings as single letters like: "a", "b", and "c". You "if/else if" should cover 6 cases for the these possible input order: abc, acb, bac, bca, cab, cba. Regardless of the input order the output should be always abc. First "if" condition check is like: if ( strcmp(name1,name2) < 0 && strcmp(name2,name3) < 0 ) cout << name1 << " " << name2 << " " << name3 << endl; You have to complete the rest of the 5 "else if" condition. The last "else" can be used to…arrow_forwardQ1: The local Driver's License Office has asked you to write a program that grades the writ- ten portion of the driver's license exam. The exam has 20 multiple choice questions. Here are the correct answers: 1. A 2. D 3. B 4. B 5. C 6. B 7. A 8. B 9. C 10. D 11. A 12. C 13. D 14. B 15. D 16. C 17. C 18. A 19. D 20. B Your program should store the correct answers shown above in an array. It should ask the user to enter the student's answers for each of the 20 questions, and the answers should be stored in another array. After the student's answers have been entered, the program should display a message indicating whether the student passed or failed the exam. (A student must correctly answer 15 of the 20 questions to pass the exam.) It should then display the total number of correctly answered questions, the total number of incorrectly answered questions, and a list showing the question numbers of the incorrectly answered questions. Input Validation: Only accept the letters A, B, C, or…arrow_forwardFrench Articles: French country names are feminine when they end with the letter e, masculine otherwise, except for the following which are masculine even though they end with e: le Belize le Cambodge le Mexique le Mozambique le Zaïre le Zimbabwe Write a program that reads the French name of a country and adds the article: le for masculine or la for feminine, such as le Canada or la Belgique. However, if the country name starts with a vowel, use l’; for example, l’Afghanistan. For the following plural country names, use les: les Etats-Unis les Pays-Basarrow_forward
- Python allows _____ parameter assignments. A. named B. positional C. named and positional D. only tuple Which one?arrow_forwardFollow this to code. Please write algo to understand.arrow_forwardTake a string from the user and then separate all the characters in the reverse order from that string and print all these separated by " In c# languagearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Computer Programming for Beginners | Functions, Parameters & Arguments | Ep24; Author: Programming With Avelx;https://www.youtube.com/watch?v=VXlh-qJpfw0;License: Standard YouTube License, CC-BY