Big Java Late Objects
2nd Edition
ISBN: 9781119330455
Author: Horstmann
Publisher: WILEY
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 2.2, Problem 12SC
The volume of a sphere is given by
If the radius is given by a variable radius of type double, write a Java expression for the volume.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
please do it in java programming
In JAVA
ASSIGNMENT DESCRIPTION:
A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-life of about 6 hours in humans. Given caffeine amount (in mg) as input, output the caffeine level after 6, 12, and 24 hours.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:System.out.printf("After 6 hours: %.2f mg\n", yourValue);
Ex: If the input is:
100
the output is:
After 6 hours: 50.00 mg After 12 hours: 25.00 mg After 24 hours: 6.25 mg
Note: A cup of coffee has about 100 mg. A soda has about 40 mg. An "energy" drink (a misnomer) has between 100 mg and 200 mg.
THE CODE I HAVE SO FAR:
import java.util.Scanner;
public class LabProgram {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
double caffeineMg; // "double" supports floating-point like 75.5, versus int for integers like 75.
caffeineMg = scnr.nextDouble();
System.out.printf("After…
A Newton number is a 4-digit integer number for which the sum of its digits to power 4 is equal to the
number itself. Example of a Newton number is 1634 since:
1634 1*1*1*1+6*6*6*6+3*3*3*3+4*4*4*4 which is: 1+ 1296+256+81.
Write a Java program that checks whether or not a number is a Newton number.
Sample Run1:
Enter an integer number of 4 digits: 3712
3712 is not a Newton number
Sample Run2:
Enter an integer number of 4 digits: 1634
1634 is not a Newton number
Sample Run2:
Enter an integer number of 4 digits: 234
Invalid input!!
Chapter 2 Solutions
Big Java Late Objects
Ch. 2.1 - Declare a variable suitable for holding the number...Ch. 2.1 - What is wrong with the following variable...Ch. 2.1 - Declare and initialize two variables, unitPrice...Ch. 2.1 - Prob. 4SCCh. 2.1 - Some drinks are sold in four-packs instead of...Ch. 2.1 - Prob. 6SCCh. 2.1 - Prob. 7SCCh. 2.1 - Prob. 8SCCh. 2.1 - How would you explain assignment using the parking...Ch. 2.2 - A bank account earns interest once per year. In...
Ch. 2.2 - In Java, how do you compute the side length of a...Ch. 2.2 - The volume of a sphere is given by V=43r3 If the...Ch. 2.2 - Prob. 13SCCh. 2.2 - Prob. 14SCCh. 2.3 - Write statements to prompt for and read the users...Ch. 2.3 - What is wrong with the following statement...Ch. 2.3 - Prob. 17SCCh. 2.3 - What is problematic about the following statement...Ch. 2.3 - What is the output of the following statement...Ch. 2.3 - Using the printf method, print the values of the...Ch. 2.4 - Prob. 21SCCh. 2.4 - Suppose the architect specifies a pattern with...Ch. 2.4 - A robot needs to tile a floor with alternating...Ch. 2.4 - For a particular car, repair and maintenance costs...Ch. 2.4 - The shape of a bottle is approximated by two...Ch. 2.5 - What is the length of the string "Java Program"?Ch. 2.5 - Consider this string variable. String str = "Java...Ch. 2.5 - Use string concatenation to turn the string...Ch. 2.5 - Prob. 29SCCh. 2.5 - Prob. 30SCCh. 2 - Write declarations for storing the following...Ch. 2 - What is the value of mystery after this sequence...Ch. 2 - What is wrong with the following sequence of...Ch. 2 - Write the following mathematical expressions in...Ch. 2 - Write the following Java expressions in...Ch. 2 - What are the values of the following expressions?...Ch. 2 - What are the values of the following expressions,...Ch. 2 - What are the values of the following expressions?...Ch. 2 - Assuming that a and b are variables of type int,...Ch. 2 - Suppose direction is an integer angle between 0...Ch. 2 - Find at least five compile-time errors in the...Ch. 2 - Find three run-time errors in the following...Ch. 2 - Consider the following code segment. double...Ch. 2 - Explain the differences between 2, 2.0, 2, 2, and...Ch. 2 - Explain what each of the following program...Ch. 2 - Write pseudocode for a program that reads a word...Ch. 2 - Write pseudocode for a program that reads a name...Ch. 2 - Write pseudocode for a program that computes the...Ch. 2 - Modify the pseudocode for the program in How To...Ch. 2 - Prob. 20RECh. 2 - You are cutting off a piece of pie like this,...Ch. 2 - The following pseudocode describes how to obtain...Ch. 2 - Suppose you are given a string str and two...Ch. 2 - Prob. 24RECh. 2 - For each of the following computations in Java,...Ch. 2 - Prob. 26RECh. 2 - This chapter contains a number of recommendations...Ch. 2 - Write a program that displays the dimensions of a...Ch. 2 - Write a program that computes and displays the...Ch. 2 - Write a program that reads a number and displays...Ch. 2 - Write a program that prompts the user for two...Ch. 2 - Enhance the output of Exercise E2.4 so that the...Ch. 2 - Write a program that prompts the user for a...Ch. 2 - Write a program that prompts the user for a radius...Ch. 2 - Write a program that asks the user for the lengths...Ch. 2 - Improve the program discussed in How To 2.1 to...Ch. 2 - Write a program that helps a person decide whether...Ch. 2 - Write a program that asks the user to input The...Ch. 2 - File names and extensions. Write a program that...Ch. 2 - Write a program that reads a number between 1,000...Ch. 2 - Write a program that reads a number between 1,000...Ch. 2 - Printing a grid. Write a program that prints the...Ch. 2 - Write a program that reads in an integer and...Ch. 2 - Write a program that reads two times in military...Ch. 2 - Writing large letters. A large letter H can be...Ch. 2 - Write a program that transforms numbers 1, 2, 3, ,...Ch. 2 - Write a program that prints a Christmas tree:...Ch. 2 - Easter Sunday is the first Sunday after the first...Ch. 2 - In this project, you will perform calculations...Ch. 2 - The following pseudocode describes how a bookstore...Ch. 2 - The following pseudocode describes how to turn a...Ch. 2 - The following pseudocode describes how to extract...Ch. 2 - Giving change. Implement a program that directs a...Ch. 2 - An online bank wants you to create a program that...Ch. 2 - A video club wants to reward its best members with...Ch. 2 - Consider the following circuit. Write a program...Ch. 2 - The dew point temperature Td can be calculated...Ch. 2 - The pipe clip temperature sensors shown here are...Ch. 2 - Prob. 12PPCh. 2 - Consider the following tuning circuit connected to...Ch. 2 - According to the Coulomb force law, the electric...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What is an uninitialized variable?
Starting Out with Programming Logic and Design (4th Edition)
Consider the adage Never ask a question for which you do not want the answer. a. Is following that adage ethica...
Experiencing MIS
The following function accepts an i nt argument and returns half of its value as a double: double half(int numb...
Starting Out with C++ from Control Structures to Objects (8th Edition)
Suppose that n0 and n1. Show that the substitution v=y1n transforms the Bernoulli equation dy/dx+P(x)y=Q(x)yn i...
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Revise the loop shown in Listing 4.6 to use a break statement instead of the boolean variable areMore. Comment ...
Java: An Introduction to Problem Solving and Programming (7th Edition)
Porter’s competitive forces model: The model is used to provide a general view about the firms, the competitors...
Management Information Systems: Managing The Digital Firm (16th 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
- Use java code Body Mass Index (BMI) is a measure of health on weight. It can be calculated by taking your weight in kilograms and dividing by the square of your height in meters. The interpretation of BMI for people 16 years or older is as follows: BMI below 16 16-18 19-24 25-29 30-35 above 35 Interpretation seriously underweight underweight normal weight overweight seriously overweight gravely overweight Write a Java program that prompts the user to enter a weight in kilograms and height in meter and display the BMI. Use nested if- else statements to solve this exercise. Here is a sample run: Enter weight in kilograms: 66.22 Enter height in meters: 1.788 Your BMI is 20.71353142 You are normal weightarrow_forwardWrite a complete Java program that performs the following tasks: Ask the user to enter the last two digits of his/her student ID. Break the number into two digits using arithmetic operators, then store the first and second digits in integer variables named digit1 and digit2 Find and print the following: The product of digit1 and digit2. The sum of digit1 and digit2 The average of digit1 and digit2 The maximum of the two numbers; digit1 digit2 using a method from the class Math. Note: The class name of your Java program must be your first name. Your answer should have the code as text as well as the screenshot of the program output (using your own student ID) as a part of your answer. Otherwise, zero marks will be awarded.arrow_forwardWrite a Java regular expression for each of the following: a. Phone numbers, such as (609) 555-1234 b. Social Security numbers, such as 123-45-6789 c. Dates, such as December 31, 1999arrow_forward
- The body mass index, BMI, is a measure used to determine if a person is overweight or not. We can calculate BMI from the weight of the person (in pounds) and the height (in inches) of the person.The formula for calculating BMI is:BMI = (weightInPounds * 703) divided by (heightInInches squared)In this problem, you will develop a Java program as a BMI calculator, that reads the user’s weight in pounds and height in inches, then calculates and displays the user’s body mass index BMI. Also, display the following information {from the US Department of Health} so the user can evaluate his/her BMI:BMI values:Underweight: less than 18.5Normal: between 18.5 and 24.9Overweight: between 25 and 29.9Obese: 30 or greaterarrow_forwardPlease im using Program netbeansarrow_forwardPlease solve it by javaarrow_forward
- An Armstrong number is a 3-digit integer number for which the sum of cube of its digit is equal to the number itself Example of Armstrong number is 153 as 153= 1*1*1+5*5*5+ 3*3*3 which is: 1+ 125+27 Another Armstrong number is 371. Write a Java program that checks whether a number is an Armstrong number or not Sample Run1: Enter an integer nunber of 3 digits: 371 371 is an Armstrong number Sample Run2: Enter an integer number of 3 dicits: 171 1 is mot an Amstrong number Sample Run2: Enter an integer number 3 digits: 2345 10:43 AM 4/16/2021arrow_forwardSubject: Java Programmingarrow_forwardjava problem: 1.predict future precipitation pattern for one month: oneMonthGenerator 2.find the number of wet or dry days in a given month’s forecast: numberOfWetDryDays 3.find the longest wet or dry spell in a given month’s forecast: lengthOfLongestWetDrySpellarrow_forward
- I want solution with stepsarrow_forwardFor an invoice calculation program, write the JAVa program that calculates the amount of VAT and the price of goods or services excluding VAT, according to the VAT rate and the total amount including VAT entered on the keyboard. (Total amount including VAT = cost of goods services excluding VAT X VAT rate + price of goods services excluding VAT)arrow_forwardAn Armstrong number is a 3-digit integer number for which the sum of cube of its digit is equal to the number itself. Example of Armstrong number is 153 as 153= 1*1*1 + 5*5*5 + 3*3*3. which is: 1+ 125+27. Another Armstrong number is 371. Write a Java program that checks whether a number is an Armstrong number or not Sample Run1: Enter an integer number of 3 digits: 371 371 is an Armstrong number Sample Run2: Enter an integer number of 3 digits: 171 171 is not an Armstrong number Sample Run2: Enter an integer number of 3 digits: 2345 Invalid input!!arrow_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
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY