What's new

Java. pahelp po

Oden Sama

Forum Veteran
Established
Using your preferred IDE or this You do not have permission to view the full content of this post. Log in or register now., create a program that asks the user to enter a number of male and female students registered in a class/section. The program should display the total number of students and the percentage of males and females in the class.



Sample output:

Enter the number of males: 36
Enter the number of females: 17
Number of students = 53
Male = 67.92%
Female = 32.08%


Screenshot your code and output then upload the images to this Dropbox.

eto po yung instruction.
 
marami na ako nakita same lng kayo ng request.
pa move sa help section. meron na ako code nito.

1637335293778.png
 

Attachments

wait lng.

[Hidden content]
marked as solved nlng.
gawan mo konting modification. pwede rin.
For Patients


public class Patient {
//Declaring variables to be used
Scanner scan=new Scanner(System.in);
String firstName;
String lastName;
String address;
long contact;
int age;
String ***;
String disease;
int id;
public Method(parametrs) {
//body
}
}


Ano po output neto
 
For Patients


public class Patient {
//Declaring variables to be used
Scanner scan=new Scanner(System.in);
String firstName;
String lastName;
String address;
long contact;
int age;
String ***;
String disease;
int id;
public Method(parametrs) {
//body
}
}


Ano po output neto
reload thread. na post ko na.
 
For Patients


public class Patient {
//Declaring variables to be used
Scanner scan=new Scanner(System.in);
String firstName;
String lastName;
String address;
long contact;
int age;
String ***;
String disease;
int id;
public Method(parametrs) {
//body
}
}


Ano po output neto
no output. incomplete code.
 
no output. incomplete code.
1637338288013.png

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);

double males, females, students ;


System.out.print("Enter the number of males: ");
males = scan.nextInt();

System.out.print("Enter the number of females: ");
females = scan.nextInt();

System.out.print("Number of students: ");
students = scan.nextInt();

males = males * 100/students;
System.out.printf("males = %.2f " , males);
System.out.println();
females = females * 100/students;
System.out.printf("females = %.2f " , females);
System.out.println();
}

}


ask ko lang sir pano dagdagan ng % yung output ahhaah. hindi kasi pwede yung nabigay nyong code kasi hindi pa natuturo samin yung ibang code dun kaya gumawa nalang ako.
 

Attachments

View attachment 1720897
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);

double males, females, students ;


System.out.print("Enter the number of males: ");
males = scan.nextInt();

System.out.print("Enter the number of females: ");
females = scan.nextInt();

System.out.print("Number of students: ");
students = scan.nextInt();

males = males * 100/students;
System.out.printf("males = %.2f " , males);
System.out.println();
females = females * 100/students;
System.out.printf("females = %.2f " , females);
System.out.println();
}

}


ask ko lang sir pano dagdagan ng % yung output ahhaah. hindi kasi pwede yung nabigay nyong code kasi hindi pa natuturo samin yung ibang code dun kaya gumawa nalang ako.
System.out.println("Male = "+String.format("%.2f",result_male)+"%");
manual add yung percent symbol.
 

Similar threads

Back
Top