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
EBK JAVA PROGRAMMING
- 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_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_forwardPlease 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_forward
- Instructions 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_forwardCreate an application that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows:1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Do not display the computer’s choice yet.)2. The user selects his or her choice of rock, paper, or scissors. To get this input you can use Button controls, or clickable PictureBox controls displaying some of the artwork that you will find in the student sample files.3. The computer’s choice is displayed.4. A winner is selected according to the following rules:• If one player chooses rock and the other player chooses scissors, then rock wins. (Rock smashes scissors.)• If one player chooses scissors and the other player chooses paper, then scissors wins. (Scissors cuts paper.)• If one player chooses…arrow_forward
- A method's type is also its _____________________. a. scope b. accessibility c. parameter type d. return typearrow_forwardWrite the C# application SwimmingWaterTemperature containing a variable that can hold a temperature expressed in degrees Fahrenheit. Within the class, create a method that accepts a parameter for a water temperature and returns true or false, indicating whether the water temperature is between 70 and 85 degrees and thus comfortable for swimming. If the temperature is not between 32 and 212 (the freezing and boiling points of water), it is invalid, and the method should throw an ArgumentException. In the Main() method, continuously prompt the user for data temperature, pass it to the method, and then display the following messages indicating whether the temperature is comfortable, not comfortable, or invalid: X degrees is comfortable for swimming. X degrees is not comfortable for swimming. Value does not fall within the expected range. Enter the value 999 to quit the program. using System; using static System.Console; class SwimmingWaterTemperature { static void Main() {…arrow_forwardCreate a program named Reverse3 whose Main() method declares three integers named firstInt, middleInt, and lastInt. Assign the following values to the integers: 23 to firstInt45 to middleInt67 to lastIntThen display the values and pass them to a method named Reverse that accepts them as reference variables, places the first value in the lastInt variable, and places the last value in the firstInt variable. In the Main() method, display the three variables again, demonstrating that their positions have been reversed. using static System.Console; class Reverse3 { static void Main() { // Write your main here } public static void Reverse(ref int a, ref int b, ref int c) { } } This is what I have and it doesn't work using static System.Console; class Reverse3 { static void Main() { int firstInt = 23; int middleInt = 45; int lastInt = 67; Console.WriteLine("Before reversing: firstInt: " + firstInt + ",…arrow_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