After having done the hand calculation and pseudocode for a program that models inflating a...
Question:
After having done the hand calculation and pseudocode for a program that models inflating a spherical balloon, now implement the task in Java. Remember, first the balloon is inflated to have a certain diameter (which is provided as an input). Then you inflate the balloon so that the diameter grows by an inch, and display the amount the volume has grown. Repeat that step: grow the diameter by another inch and show the growth of the volume.
Complete the following program.
import java.util.Scanner;
public class Balloon { public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Diameter: ");
double diameter = in.nextDouble();
. . .
System.out.printf("Increase: %.0f", . . .);
System.out.println();
. . .
System.out.printf("Increase: %.0f", . . .);
System.out.println();
}
}
Pi Number in JAVA:
While one can create a variable, such as with the name 'pi' and assign some close value to real pi, he can also use the built-in pi number in java by accessing via Math.PI.
Answer and Explanation: 1
Become a Study.com member to unlock this answer! Create your account
View this answerJava code below:
import java.util.Scanner;
public class Balloon {
public static void main(String[] args) {
&...
See full answer below.
Ask a question
Our experts can answer your tough homework and study questions.
Ask a question Ask a questionSearch Answers
Learn more about this topic:
from
Chapter 6 / Lesson 4A method in a Java program provides a set of instructions to be executed. Explore the different components of a method, such as its parameters and ability to return a value, and learn how to create a method.
Related to this Question
- First, write out the pseudocode and then create a program to help you by accomplishing the following tasks (using NetBeans). Write TWO Java codes: 1 pseudocode and then 1 actual code that is derived f
- Write a Java program that performs the following mathematical tasks in the following order, using double values for all input and calculations and Math.PI when the value of pi is required. Ask the use
- Write a Java console application that approximates PI. Use a validation loop to prompt and get from the user the number of terms to approximate PI to that is at least 1. Use the following Leibniz form
- JAVA: You've been hired by Nocturnal Nerds to write a Java console application that approximates PI. Use a validation loop to prompt and get from the user the number of terms to approximate PI to that
- Write a Java program that takes two ints as input from the keyboard that represent the number of hits and the number of at-bats for a batter. Then calculate the batter's hitting percentage, and check
- You've been hired by Nocturnal Nerds to write a Java console application that approximates PI. Use a validation loop to prompt and get from the user the number of terms to approximate PI to that is at
- Java Programming Generate a 8 to 10-row "double" Pascal triangle as per the instructions shown in the attached slides. Use a recursive method to generate the Pascal Triangle.
- Write a Java program named InterestCalculator.java that calculates the value of a bank account based on starting principle, interest rate and time. The program must Prompt the user for Number of quar
- Ackermann's function is a recursive mathematical algorithm that can be used to test how well a computer performs recursion. Using Java, write a method ackermann(m, n), which solves Ackermann's functio
- You must use Java Object Oriented Programming to design this project. Write a reservation system for an airline flight. Assume the airplane has 10 rows with 4 seats in each row. Use a two-dimensional
- Use Java Object Oriented Programming to design this project. Write a reservation system for an airline flight. Assume the airplane has 10 rows with 4 seats in each row. Use a two dimensional array of
- You must use Object Oriented Java Programming to design this project. Write a reservation system for an airline flight. Assume the airplane has 10 rows with 4 seats in each row. Use a two-dimensional
- Write a Java class that implements the concept of Coins, assuming the following attributes (variables): number of quarters number of dimes number of nickels number of pennies Include two constructors
- Write a program in JAVA that evaluates infix expressions of unsigned integers using two stacks. The program should consist of three classes. The main class should create a GUI that allows the user inp
- Write a recursive method in JAVA to calculate the size of a population of organisms that increases at a specified rate each day. The method header is: public int populationSize(int startingPopulation,
- In Java, create a Circles class and tester. The Circle class represents a circle. A circle has a color ("red", "yellow", or "blue") and a radius. Separate circle methods return the color, calculate an
- Write a Java program that does the following: Initialize a counter to 0. Get input for the number of calculations to perform. (Calculations are to be performed in a looping structure.) Add 2 to the co
- Write a Java program that reads the subtotal and the gratuity rate from a user for a service. Your program should compute the gratuity and the total and then output the subtotal entered, the gratuity
- Write a Java class that implements the concept of Coins, assuming the following attributes (variables): number of quarters, number of dimes, number of nickels, and number of pennies. Include two cons
- Develop an algorithm based on C++ by using top-down design, stepwise refinement, and code:blocks. The program should prompt the user for the number of prix fixe meals ordered and calculate the bill in
- Write pseudocode to represent the logic of a program that allows the user to enter values for a salesperson's base salary, total sales, and commission rate. The program computes and outputs the salesp
- Write a complete Java program to compute the total living cost for a semester at college. The main method calls three methods to do this: 1. getTotalWeeks: Requests from the user the total number of w
- Write a Java program that draws a pattern of hexagons. The vertices of a (regular) hexagon lie on its so-called circumscribed circle. The user must be able to specify the radius of this circle by clic
- Write a complete Java program to compute the total living cost for a semester at college. * The main method calls three methods to do this: 1. getTotalWeeks: requests from the user the total num
- Use Java for the following. You must use Object Oriented Programming to design this project. Write a reservation system for an airline flight. Assume the airplane has 10 rows with 4 seats in each row.
- Write a program in C++ to develop an algorithm to simulate a single elevator in a 10-story building. There will be some simplifying assumptions that will make this a bit less complex than a real-world
- Explain how to write pseudocode for A,B,C and the actual code for B,C. Consider the Homework Point Sum problem below. The problem states: Get all homework scores for one student, calculate and displ
- Write a Java program using methods to compute and output the area of an n sided polygon where the area is defined by the following mathematical formula: area = (n*(s*s))/(4 x tan(3.1416/n)) where s=
- Write the pseudocode for these two problems: 1. Kevin wants a program to total the votes each district in his state cast for the independent delegate running in a given election. There are 10 district
- ****Java**** For this assignment, refer to the StaffMember class hierarchy Diagram, write the main program to perform the following tasks. (Staff, StaffMemeber, Executive, Hourly and Volunteer class f
- How to programme in java to multiply two integers without using multiplication?
- Write a pseudocode to design a modular logic for a program that allows a user to enter 12 numbers, then displays all of the numbers, the largest number and the smallest. Note: Your program logic must
- JAVA HOMEWORK 1. The choice of algorithm is important, however, because it affects ( ? ) of the program. Select one: a. only the run time b. only the memory use c. the run time and the memory use d. n
- At Google, a group of programmers are trying to solve a complicated problem that has 148 function points. They are planning to use Java for that problem. Arnold has been assigned to manage the project
- Write a Java application that accomplishes the following tasks: Prompts users to enter the number of students and their names in this course. Displays the total number of students in the class and the
- (JavaFX) Write a program that uses a pie chart to display the percentages of the overall grade represented by projects, quizzes, midterm exams, and the final exam. Suppose that projects take 20 percen
- Write a program in C++ to simulate a lottery drawing which uses balls that are numbered from 1 to 10. Assume that three balls are drawn at random and the number are unique for each draw. (all 3 numbe
- Java: In this assignment you will write a java program that plays an interactive guessing game with the user. Your program will generate a random integer in the range 1 to 10, then allow the user thre
- Write the pseudocode for the manager of the Jeter County softball team, who wants to compute batting averages for his players. A batting average is computed as hits divided by at-bats and is usually e
- Using the Java Development Kit and jGrasp, develop a program in response to the following prompt. Write a program that prompts the user to input a decimal number and outputs the number rounded to the
- Using Java, you will create a game that has the user guess a number between 1 and 10. Generate a random number that the user will attempt to guess. If the user guesses a number that is lower than the
- Complete the following program. Complete the following file: Balloon.java import java.util.Scanner; public class Balloon { public static void main(String[] args) { Scanner in = new Scanner(System.in);
- Write a java code for 8 times multiplication table.
- Write JAVA code to perform the following functions in sequence (1) Prompt the user to enter five numbers, being five people's weights. (2) Store the numbers in an array of doubles. (3) Output the a
- Does Java support procedural programming?
- Create a Java program to organize sheep in a heap. Fat sheep should go on the bottom, so they don't crush the skinny sheep. Sheep have: o Name o Weight The heap (HINT: min-heap) should have the follow
- JAVA: This is a simulation of rolling dice. We will roll 10,000 times in our program. The theoretical probability of rolling doubles of a specific number is 1 out of 36 or approximately 278 out of 10,
- 1. Write algorithm for a game where the user guesses a number from 1 to 10 and call it OneToTen-algorithm.txt for a game where the user guesses a number from 1 to 10 and call it OneToTen-algorithm.txt.
- Create a JAVA GUI that contains three classes: Main, Account, and InsufficientFunds. The second project involves writing a program that implements an ATM machine. The program should consist of three c
- Pseudocode only. No using java, python, or c++ Design a class named Pet, which should have the following fields: name: The name field holds the name of a pet. type: The type field holds the type of
- Create your own simple Java application to generate X random Integer values between 0 and Y. Use command line arguments for entry of X and Y. Demonstrate your code compiles and runs without issue usin
- (Java Programming Question) Synopsis: Create a program that reads solar energy production data for the last week from a file, gets input for the cost of the system, and outputs production, savings, da
- Jave Write a class encapsulating the concept of coins, assuming that coins have the following attributes: a number of quarters, a number of dimes, a numbers of nickels, and a number of pennies. Inclu
- Write code for a java class that declares a variable named inches that holds a length in inches, assigns it a value and a method to display the value in feet and inches using a named constant as appr
- Write a java program that takes as input an arithmetic expression. The program outputs whether the expression contains matching grouping symbols. For example, the arithmetic expressions {25 + (3 - 6)
- (Java) Write a program which creates a binary search tree of different shapes from a file. -- The comparison is based on the shape's area -- There are 3 shapes o Rectangle o Circle o Right Triangle --
- Write a Java class that implements the concept of Coins, assuming the following attributes (variables): number of quarters, number of dimes, number of nickels, and number of pennies. Include two const
- PYTHON PROGRAMMING Geometry Calculator Write a program that displays the following menu: Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate t
- Covert the following pseudocode to Java code. Be sure to declare the appropriate variables: Store 172.5 in the force variable. Store 27.5 in the area variable Divide area by force and store the res
- Write an interactive Java program. Create a Student class that contains basic information about a student. Create a Course class that stores information about a course (test grades, quiz grades, proje
- Give a big-O estimate of the complexity of the Base algorithm procedure Base (n: positive integer, b: positive integer greater than 1) q:=n k:=0 while q \ne 0 begin a_k:=q mod b q:= q div b k:= k + 1
- In JAVA, you will implement and test a preliminary version of the polynomial class, using a small array to store the coefficients of the polynomial in order, following the design pattern of object-ori
- Write a computer program (in your preferred programming language) that calculates the approximate value of sin(x) using the Maclaurin series approximation sin x=x-x^3 3! + x^5 5! - x^7 7! + up to 8 s
- JAVA: Write a program which creates a binary search tree of different shapes from a file. - The comparison is based on the shape's area - There are 3 shapes o Rectangle o Circle o Right Triangle - The
- 1. Write a recursive program that calculates m to the nth power. Instead of iteratively multiplying m n times, you will compute the result recursively by performing successive multiplication operation
- Create a simple Java application to generate X random integer values between 0 and Y. Use command-line arguments for the entry of X and Y. Demonstrate that the code compiles and runs without issues.
- Write a recursive program that calculates m to the nth power. Instead of iteratively multiplying m n times, you will compute the result recursively by performing successive multiplication operations.
- Design and implement a Java program called CrapsGame. Rolling a die is simply generating a random integer number between 1 and 6. Write a separate method for this function, call it rollDie(), to retu
- Java Programming Implement a minimum (min) heap of integers, and write a driver to demonstrate its functionality. Min heaps work the same way as maximum (max) heaps except the a parent is always small
- Write a program in Java which would ask for the clerk to enter the total amount of the customer's order. The program will then calculate a seven percent (7%) sales tax. Commission is computed based o
- Create a complete Java program called CalcAvgDropLowest that prompts the user for 5 to 10 numbers all on one line, separated by spaces; calculates the average of all those numbers except the lowest n
- Design and write an algorithm to convert the change given in quarters, dimes, nickels, and pennies into pennies.
- Create a basic, complete Java program called PatternMaker according to the following guidelines. The program prompts the use for five input values: an integer value between 1 and 10 (inclusive) for th
- In the C++ programming language, write a program capable of playing 3-D tic-tac-toe against the user. Your program should use OOP concepts in its design. Use Inheritance to create a derived class from
- Using Java, write a complete Java program that draws a scatterplot by reading in points of data from a file and displaying them. The input data file consists of a pair of integers representing a point
- Write an interactive java program. Create a Student class that contains basic information about a student. Create a Course class that stores information about a course (test grades, quiz grades,
- Write an application to demonstrate simple use of Java Swing objects JPanel and JButton. Initially, the code should display a fixed phrase in a large font within a JPanel. On clicking of a suitably pl
- Write a java method named printfactors that accepts an integer as its parameter and uses a fencepost loop to print the factors of that number separated by the word "and". For example :the number 24's
- (Java) Write each of these methods in the Unit6ProblemSet.java class. When you are finished, compress the Unit6ProblemSet NetBeans folder. Exercises to be completed: 1. Write a method called bannerPri
- Write a Java class encapsulating a board game which inherits from Game. A board game has the following additional attributes: the number of players and whether the game can end in a tie. Code the cons
- Create java program that outputs the multiplication table from 1 to 9 "for" loops. Your program must do the multiplication for each number in the table.
- Design and implement a Java program (name it WeeklyHours). The program prompts the user to enter a 2-dimensional array representing employees work hours for each day of the week. The program prints ou
- Implement a java program that will use a stack structure to check for correct placement of parentheses in an algebraic expression. Allow the use of ()[] {} characters as grouping symbols. Make sure
- // Arithmetic2.java - This program performs arithmetic, ( +. -, *. /, % ) on two numbers // Input: Interactive. // Output: Result of arithmetic operation import javax.swing.*; public class Arithmet
- Design an implement a recursive program to determine and print the Nth line of Pascal's Triangle. Each interior value is the sum of the two values above it. (Hint: use an array to store the values on
- Java: Write a complete Java program that draws a scatterplot by reading in points of data from a file and displaying them. The input data file consists of a pair of integers representing a point on ea
- Problem 1 Write a program in JAVA to accomplish the following tasks: 1. make an array of the size 10; 2. fill the array with random integers from 0 to 999; 3. print lines of output for each of these:
- Write a Java program that prompts the user to enter a length in feet and inches and then outputs the equivalent length in inches and in centimeters. If the user enters a negative number or a nondigit
- List the: inputs, outputs, pseudocode, flowchart, desk check and C++ code as a .cpp file. Problem: Write a program that reads in the radius and length of a cylinder and computes the area and volume us
- Draw the hierarchy chart and design the logic for a program that calculates the projected cost of an automobile trip. Assume that the user's car travels 20 miles per gallon of gas. Design a program th
- Write a Java Program. Write a class Bug that models a bug moving in the x-y plane. The bug either moves north, east, south, or west. Initially, the bug moves to the north, but it can turn to the right
- (Java) Write a program that plots the sine function in red and cosine in blue, using JavaFx.
- In C++ develop a recursive function to determine the number of distinct ways in which a given amount of money in cents could be changed into quarters, dimes, nickels, and pennies. For example, if the
- Before attempting this project, be sure you have completed all of the reading assignments, hands-on labs, discussions, and assignments to date. Design, implement and test a Java application that will
- For this assignment, write a Java application that prompts the user for pairs of inputs of a product number (1-5), and then an integer quantity of units sold (these are two separate prompts for input
- Pick one of the following programming languages: C, C++, Java, or Python. Implement the following three recursive functions. 1. The factorial function accepts a nonnegative integer as the argument n a
- Write a complete program using Java that draws a scatterplot by reading in points of data from a file and displaying them. The input data file consists of a pair of integers representing a point on ea
- In Java, design and implement a set of classes that define the employees of a hospital: doctor, nurse, administrator, surgeon, receptionist, janitor, and so on. include methods in each class that are
- Use Java for this assignment. Write a complete program that draws a scatterplot by reading in points of data from a file and displaying them. The input data file consists of a pair of integers represe
- Draw a flowchart or write pseudocode for a program that allows the user to enter values for the length and width, in feet, of a wall. The program outputs the area of the wall, in square feet. Then mod