1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
tamaranim1 [39]
3 years ago
6

Write a program that asks the user for the number of males and the number of females registered in a class. The program should d

isplay the percentage of males and females in the class. Hint: Suppose there are 8 males and 12 females in a class. There are 20 students in the class. The percentage of males can be calculated as: (8/20) * 100, or 40%. The percentage of females can be calculated as: (12/20) * 100, or 60%.
Computers and Technology
1 answer:
Bond [772]3 years ago
4 0

Answer:

import java.util.Scanner;

public class PercentagePopulation {

public static void main(String[] args) {

 // 1. Create an object of the Scanner class

 // This will allow for user's inputs

 Scanner input = new Scanner(System.in);

 // 2. Create a prompt asking the user to enter the number of males

 System.out.println("Please enter the number of males");

 // 3. Receive the number entered by the user and store in an int

 // variable called  number_of_males.

 int number_of_males = input.nextInt();

 // 4. Create a prompt asking the user to enter the number of

               // females

 System.out.println("Please enter the number of females");

 // 5. Receive the number entered by the user and store in an int

 // variable  called, number_of_females

 int number_of_females = input.nextInt();

 // 6. Find the sum of the number of males and females

 // Store the result in an int variable called total.

 int total = number_of_males + number_of_females;

 // 7. Find the percentage of males by using the appropriate

 // formula.  Do a type-casting to allow for division in floating point

               // representation by prepending the number_of_males by (double)

 double percentagemales = (double) number_of_males / total * 100.0;

 // 8. Find the percentage of females by using the appropriate

 // formula.  Do a type casting to allow for division in floating point

               // representation by prepending the number_of_males by (double)

 double percentagefemales = (double) number_of_females / total * 100.0;

 // 9. Print out the results

 System.out.println("Percentage males : " + percentagemales + "%");

 System.out.println("Percentage females : " + percentagefemales + "%");

}

}

Explanation:

Please go through the comments in the code to give an explanation of the program. The source code file has also been added to this response. Please download it and go through it.

Download java
You might be interested in
What does the label display when the user clicks the button? void btnSubmit_Click(object sender, EventArgs e) { int num1 = 3; in
erma4kov [3.2K]

Answer:

10

Explanation:

num1=3 and num2=2

num3=myproc(num1)+myproc(num2)

myproc(num1) results 6

myproc(num2) results 4

when we add both e get 10

6 0
3 years ago
________ are viruses that masquerade as useful programs or files. hydras spyware programs worms adware programs trojan horses
Harrizon [31]
Trojan horse is the correct answer
5 0
3 years ago
Which of these statements is true about database reports? A. A generated report will include all records in the database. B. A g
weeeeeb [17]

B. A generated report will include all records that a query fetches.

6 0
3 years ago
What is 11.2 rounded to the nearest one?​
klio [65]
Your answer is already in one decimal place. If you consider the whole number to one decimal place it would be rounded to just 10 since 0 doesn’t count for sig figs. Hope it helped
4 0
3 years ago
Read 2 more answers
Which is true about TCP and UDP? Choose two answers.
natulia [17]

Answer:

Explanation:

TCP Transmission Control Protocol, is an internet protocol to exchange data, is one of the most main protocols of the internet is used from the beginning, with UPD is used to transfer data too, but is less secure than TCP, but is faster than TCP, in this case, UDP is used to transfer music or videos, and TCP is used to transfer websites and database.

3 0
3 years ago
Other questions:
  • Why is peer answer always not working? just wondering idk why
    7·2 answers
  • In Word, tables can be styled much like text can.<br> True<br> False
    6·1 answer
  • Bit stream methods commonly use algorithm functions like the exclusive or operation (__________.
    11·1 answer
  • While working on a group project, you notice something does not look right in the presentation. You call a meeting with your tea
    14·2 answers
  • Write an if-else statement to describe an object. Print "Balloon" if isBalloon is true and isRed is false. Print "Red balloon" i
    9·1 answer
  • Network address 192.10.10.0<br>​
    12·1 answer
  • Write a set of nested loops that display 10 rows of # characters. There should be 15 # characters in each row.
    15·1 answer
  • 1) "Information systems are revolutionizing the way businesses function in the 21st century," Do you agree or disagree with this
    5·1 answer
  • THIS IS TIMED PLS HURRY UP
    7·1 answer
  • Assume the name of your data frame is flavors_df. What code chunk lets you review the structure of the data frame?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!