Explanation of Solution
a.
Program code:
Percentages.java
//import the requird packages
import java.io.*;
//define a class Percentages
class Percentages
{
//define a method computePercent()
public static void computePercent(double num1,double num2)
{
//print the percentage values
System.out.println(num1+" is "+((num1/num2)*100)+" percent of "+num2+".");
}
//define the main method
public static void main (String[] args)
{
//declare two double values
double num1=2.0,num2=5...
Explanation of Solution
b.
Program code:
Percentage2.java
//import the requird packages
import java.util.Scanner;
import java.io.*;
//define a class Percentages
class Percentage2
{
//define a method computePercent()
public static void computePercent(double num1,double num2)
{
//print the percentage values
System.out.println(num1+" is "+((num1/num2)*100)+" percent of "+num2+".");
}
//define the main method
public static void main (String[] args)
{
//declare two double variables
double num1,num2;
//create the object of Scanner
Scanner sc=new Scanner(System.in);
//prompt the user to enter the values
System.out.println("Enter two numbers:");
//scan for the values
num1=sc...
Trending nowThis is a popular solution!
Chapter 3 Solutions
Java Programming (MindTap Course List)
- This assigment wants me to: Assume that a gallon of paint covers about 350 square feet of wall space. Create an application with a main() method that prompts the user for the length, width, and height of a rectangular room. Pass these three values to a method that does the following: Calculates the wall area for a room Passes the calculated wall area to another method that calculates and returns the number of gallons of paint needed Displays the number of gallons needed Computes the price based on a paint price of $32 per gallon, assuming that the painter can buy any fraction of a gallon of paint at the same price as a whole gallon Returns the price to the main() method The main() method displays the final price. For example: You will need 2.0 gallons The price to paint the room is $64.0 here is my code and this is all i have so far help please ! import java.util.Scanner; public class PaintCalculator { public static void main (String args[]) { int AreaPerGalllon =…arrow_forwardWhen you want a method to be able to change the value of a variable that is passed to it as an argument, the variable must be __________. a. passed by reference b. a local variable c. passed by value d. a named constantarrow_forward// Question 4: // Declare an integer variable named "variables with an initial value of 10. // Write a method named "SetToOne" that takes one out parameter. // The method should set the out parameter to 1. // Call the method SetToOne passing variables in the btngs click method. // Display the variable variables in the lblQ4. private void btn04_Click(object sender, EventArgs e) {arrow_forward
- To encourage good grades, Hermosa High School has decided to award each student a bookstore credit that is 10 times the student’s grade point average. In other words, a student with a 3.2 grade point average receives a $32.0 credit. Create an application that prompts a student for a name and grade point average, and then passes the values to a method (computeDiscount) that displays a descriptive message. The message uses the student’s name, echoes the grade point average, and computes and displays the credit. An example of the program is shown below: Enter your name >> John Enter your gpa >>3.4 John, your GPA is 3.4, so your credit is $34.0arrow_forward// Question 4: // Declare an integer variable named "variables with an initial value of 10. // Write a method named "SetToOne" that takes one out parameter. // The method should set the out parameter to 1. // Call the method SetToOne passing variables in the btnQ4 click method. // Display the variable variables in the lblQ4. private void btn04_Click(object sender, EventArgs e) {arrow_forwardFor this interactive assignment, you will create an application that grades the written portion of the driver’s license exam. The exam has 20 multiple-choice questions. Here are the correct answers: B 2. D 3. A 4. A 5. B 6. A 7. B 8. A 9. C 10. D B 12. C 13. D 14. A 15. D 16. C 17. C 18. B 19. D 20. A Your program should store these correct answers in a list. The program should read the student’s answers for each of the 20 questions from a text file and store the answers in another list. (Create your own answer text file to test the application.) After the student’s answers have been read from the text file, 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…arrow_forward
- Please help using Javaarrow_forward// Question 4: // 20 Points // Declare an integer variable named "variableQ4" with an initial value of 10. // Write a method named "SetToOne" that takes one out parameter. // The method should set the out parameter to 1. // Call the method SetToOne passing variableQ4 in the btnQ4 click method. // Display the variable variableQ4 in the lblQ4. 1 reference private void btnQ4_Click(object sender, EventArgs e) { }arrow_forwardPlease use Java as programming language Create a class whose main() holds two integer variables. Assign values to the variables. Create two methods named sum() and difference, that compute the sum and difference between the two variables respectively. Each method should perform the computation and display the results. In turn, call the two methods passing the values of the 2 variables. Create another method named product. The method should compute the product of the 2 numbers but will not display the answer. Instead, the method should return the answer to the calling main() which displays the answer. Provide your own screen display and class name.arrow_forward
- // Question 4: // Declare an integer variable named "variableQ4" with an initial value of 10. // Write a method named "SetToOne" that takes one out parameter. // The method should set the out parameter to 1. // Call the method SetToOne passing variableQ4 in the btnQ4 click method. // Display the variable variableQ4 in the lblQ4. 1 reference private void btnQ4_Click(object sender, EventArgs e) { }arrow_forwardInstructions Previously, you wrote a program named Admission for a college admissions office in which the user enters a numeric high school grade point average and an admission test score. The program displays Accept or Reject based on those values. Now, create a modified program named Admission Modularized in which the grade point average and test score are passed to a method that returns a string containing Accept or Reject. Grading When you have completed your program, click the Submit button to record your score. Admission Modularize... + 1 using System; 2 using static System.Console; 3 class Admission 4 { LO 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 static void Main() { double gpa; int testScore; const double MINGPA = 3.0; const int ADMIN1 = 60, ADMIN2 = 80 string inputString; WriteLine("Enter grade point averag inputString = ReadLine(); gpa = Convert.ToDouble(inputString WriteLine("Enter test score "); inputString = ReadLine(); test Score = Convert.ToInt32(inputS-…arrow_forwardPieces of data that are sent into a method are known as __________. a. arguments b. references c. method variables d. data entriesarrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage