SlideShare a Scribd company logo
1 of 6
Download to read offline
StudentData.java
import java.util.Scanner;
public class StudentData {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int totalStudents = 0;
int maleCount = 0, femaleCount = 0, minorCount = 0, adultCount = 0, seniorCount = 0;
while(true){
System.out.println("Do you ant to add a student (n to stop):");
char ch = scan.next().charAt(0);
if(ch == 'n' || ch == 'N'){
break;
}
else{
System.out.println("Enter the student gender (male or female)");
String gender = scan.next();
if(gender.equalsIgnoreCase("male")){
maleCount++;
}
else{
femaleCount++;
}
System.out.println("Enter student age:");
int age = scan.nextInt();
if(age <= 18){
minorCount++;
}
else if(age >=19 && age <= 65){
adultCount++;
}
else{
seniorCount++;
}
}
}
totalStudents = maleCount + femaleCount;
System.out.println("Total Students: "+totalStudents);
System.out.println("Male: "+maleCount);
System.out.println("Female: "+femaleCount);
System.out.println("Minor: "+minorCount);
System.out.println("Adult: "+adultCount);
System.out.println("Senior: "+seniorCount);
String s = (maleCount >= femaleCount)? "Students are mre males":"Students are more
females";
System.out.println(s);
}
}
Output:
Do you ant to add a student (n to stop):
y
Enter the student gender (male or female)
male
Enter student age:
44
Do you ant to add a student (n to stop):
y
Enter the student gender (male or female)
male
Enter student age:
77
Do you ant to add a student (n to stop):
y
Enter the student gender (male or female)
male
Enter student age:
12
Do you ant to add a student (n to stop):
yy
Enter the student gender (male or female)
female
Enter student age:
55
Do you ant to add a student (n to stop):
y
Enter the student gender (male or female)
female
Enter student age:
33
Do you ant to add a student (n to stop):
n
Total Students: 5
Male: 3
Female: 2
Minor: 1
Adult: 3
Senior: 1
Students are mre males
Solution
StudentData.java
import java.util.Scanner;
public class StudentData {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int totalStudents = 0;
int maleCount = 0, femaleCount = 0, minorCount = 0, adultCount = 0, seniorCount = 0;
while(true){
System.out.println("Do you ant to add a student (n to stop):");
char ch = scan.next().charAt(0);
if(ch == 'n' || ch == 'N'){
break;
}
else{
System.out.println("Enter the student gender (male or female)");
String gender = scan.next();
if(gender.equalsIgnoreCase("male")){
maleCount++;
}
else{
femaleCount++;
}
System.out.println("Enter student age:");
int age = scan.nextInt();
if(age <= 18){
minorCount++;
}
else if(age >=19 && age <= 65){
adultCount++;
}
else{
seniorCount++;
}
}
}
totalStudents = maleCount + femaleCount;
System.out.println("Total Students: "+totalStudents);
System.out.println("Male: "+maleCount);
System.out.println("Female: "+femaleCount);
System.out.println("Minor: "+minorCount);
System.out.println("Adult: "+adultCount);
System.out.println("Senior: "+seniorCount);
String s = (maleCount >= femaleCount)? "Students are mre males":"Students are more
females";
System.out.println(s);
}
}
Output:
Do you ant to add a student (n to stop):
y
Enter the student gender (male or female)
male
Enter student age:
44
Do you ant to add a student (n to stop):
y
Enter the student gender (male or female)
male
Enter student age:
77
Do you ant to add a student (n to stop):
y
Enter the student gender (male or female)
male
Enter student age:
12
Do you ant to add a student (n to stop):
yy
Enter the student gender (male or female)
female
Enter student age:
55
Do you ant to add a student (n to stop):
y
Enter the student gender (male or female)
female
Enter student age:
33
Do you ant to add a student (n to stop):
n
Total Students: 5
Male: 3
Female: 2
Minor: 1
Adult: 3
Senior: 1
Students are mre males

More Related Content

Similar to StudentData.javaimport java.util.Scanner; public class Student.pdf

クイズプログラム
クイズプログラムクイズプログラム
クイズプログラムMinori Fukuda
 
import java.util.Scanner;public class Digits { public static v.pdf
import java.util.Scanner;public class Digits { public static v.pdfimport java.util.Scanner;public class Digits { public static v.pdf
import java.util.Scanner;public class Digits { public static v.pdfapexelectronices01
 
import java.util.Scanner; public class Palin { public static v.pdf
import java.util.Scanner; public class Palin { public static v.pdfimport java.util.Scanner; public class Palin { public static v.pdf
import java.util.Scanner; public class Palin { public static v.pdfLAMJM
 
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...Nithin Kumar,VVCE, Mysuru
 
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdfimport java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdfshettysachin2005
 
Not sure why my program wont run.Programmer S.Villegas helper N.pdf
Not sure why my program wont run.Programmer S.Villegas helper N.pdfNot sure why my program wont run.Programmer S.Villegas helper N.pdf
Not sure why my program wont run.Programmer S.Villegas helper N.pdfwasemanivytreenrco51
 
import java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdfimport java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdfstopgolook
 

Similar to StudentData.javaimport java.util.Scanner; public class Student.pdf (10)

クイズプログラム
クイズプログラムクイズプログラム
クイズプログラム
 
Code
CodeCode
Code
 
import java.util.Scanner;public class Digits { public static v.pdf
import java.util.Scanner;public class Digits { public static v.pdfimport java.util.Scanner;public class Digits { public static v.pdf
import java.util.Scanner;public class Digits { public static v.pdf
 
Java programs
Java programsJava programs
Java programs
 
Ann
AnnAnn
Ann
 
import java.util.Scanner; public class Palin { public static v.pdf
import java.util.Scanner; public class Palin { public static v.pdfimport java.util.Scanner; public class Palin { public static v.pdf
import java.util.Scanner; public class Palin { public static v.pdf
 
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
 
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdfimport java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
 
Not sure why my program wont run.Programmer S.Villegas helper N.pdf
Not sure why my program wont run.Programmer S.Villegas helper N.pdfNot sure why my program wont run.Programmer S.Villegas helper N.pdf
Not sure why my program wont run.Programmer S.Villegas helper N.pdf
 
import java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdfimport java.util.Scanner;public class Main {private static i.pdf
import java.util.Scanner;public class Main {private static i.pdf
 

More from anokhijew

we know that there is an OH group present in phen.pdf
                     we know that there is an OH group present in phen.pdf                     we know that there is an OH group present in phen.pdf
we know that there is an OH group present in phen.pdfanokhijew
 
systems T and P are different from the reservoi.pdf
                     systems T and P are different from the reservoi.pdf                     systems T and P are different from the reservoi.pdf
systems T and P are different from the reservoi.pdfanokhijew
 
Since X represents the solid phase, Y represents .pdf
                     Since X represents the solid phase, Y represents .pdf                     Since X represents the solid phase, Y represents .pdf
Since X represents the solid phase, Y represents .pdfanokhijew
 
Pb^2+ may be present. .pdf
                     Pb^2+ may be present.                            .pdf                     Pb^2+ may be present.                            .pdf
Pb^2+ may be present. .pdfanokhijew
 
P inversly proportional to 1V so answer is C .pdf
                     P inversly proportional to 1V so answer is C    .pdf                     P inversly proportional to 1V so answer is C    .pdf
P inversly proportional to 1V so answer is C .pdfanokhijew
 
nutrinos are the smallest part of an atom. NOTE-.pdf
                     nutrinos are the smallest part of an atom. NOTE-.pdf                     nutrinos are the smallest part of an atom. NOTE-.pdf
nutrinos are the smallest part of an atom. NOTE-.pdfanokhijew
 
Molecular solids are held together in single chai.pdf
                     Molecular solids are held together in single chai.pdf                     Molecular solids are held together in single chai.pdf
Molecular solids are held together in single chai.pdfanokhijew
 
Liquid crystals (LCs) are a state of matter that .pdf
                     Liquid crystals (LCs) are a state of matter that .pdf                     Liquid crystals (LCs) are a state of matter that .pdf
Liquid crystals (LCs) are a state of matter that .pdfanokhijew
 
interstellar medium (gas) Solution .pdf
                     interstellar medium (gas) Solution           .pdf                     interstellar medium (gas) Solution           .pdf
interstellar medium (gas) Solution .pdfanokhijew
 
Hhyd = Hcrystallization + Hsolv Enthalpy of Solv.pdf
                     Hhyd = Hcrystallization + Hsolv  Enthalpy of Solv.pdf                     Hhyd = Hcrystallization + Hsolv  Enthalpy of Solv.pdf
Hhyd = Hcrystallization + Hsolv Enthalpy of Solv.pdfanokhijew
 
The answer is (b) the condensation of steam to liiquid water.The e.pdf
The answer is (b) the condensation of steam to liiquid water.The e.pdfThe answer is (b) the condensation of steam to liiquid water.The e.pdf
The answer is (b) the condensation of steam to liiquid water.The e.pdfanokhijew
 
XML Extensiable Markup LanguageHTML Hypertext Markup LanguageD.pdf
XML Extensiable Markup LanguageHTML Hypertext Markup LanguageD.pdfXML Extensiable Markup LanguageHTML Hypertext Markup LanguageD.pdf
XML Extensiable Markup LanguageHTML Hypertext Markup LanguageD.pdfanokhijew
 
The Data recovery is of two types …One method is by using a softwa.pdf
The Data recovery is of two types …One method is by using a softwa.pdfThe Data recovery is of two types …One method is by using a softwa.pdf
The Data recovery is of two types …One method is by using a softwa.pdfanokhijew
 
Thanks anon101. D is correctSolutionThanks anon101. D is corre.pdf
Thanks anon101. D is correctSolutionThanks anon101. D is corre.pdfThanks anon101. D is correctSolutionThanks anon101. D is corre.pdf
Thanks anon101. D is correctSolutionThanks anon101. D is corre.pdfanokhijew
 
Reverse EngineeringReverse engineering is also a back engineering .pdf
Reverse EngineeringReverse engineering is also a back engineering .pdfReverse EngineeringReverse engineering is also a back engineering .pdf
Reverse EngineeringReverse engineering is also a back engineering .pdfanokhijew
 
Quantum mechanics predicts the existence of what are usually called .pdf
Quantum mechanics predicts the existence of what are usually called .pdfQuantum mechanics predicts the existence of what are usually called .pdf
Quantum mechanics predicts the existence of what are usually called .pdfanokhijew
 
Program Educational Objectives • To create competencies and opportun.pdf
Program Educational Objectives • To create competencies and opportun.pdfProgram Educational Objectives • To create competencies and opportun.pdf
Program Educational Objectives • To create competencies and opportun.pdfanokhijew
 
P2O5 removes H2O from Alcohol to form Alkene O of Alcohol gives it.pdf
P2O5 removes H2O from Alcohol to form Alkene O of Alcohol gives it.pdfP2O5 removes H2O from Alcohol to form Alkene O of Alcohol gives it.pdf
P2O5 removes H2O from Alcohol to form Alkene O of Alcohol gives it.pdfanokhijew
 
cant understand a thing .pdf
                     cant understand a thing                          .pdf                     cant understand a thing                          .pdf
cant understand a thing .pdfanokhijew
 
Japanese colonial design in china korea and mongolia create an image.pdf
Japanese colonial design in china korea and mongolia create an image.pdfJapanese colonial design in china korea and mongolia create an image.pdf
Japanese colonial design in china korea and mongolia create an image.pdfanokhijew
 

More from anokhijew (20)

we know that there is an OH group present in phen.pdf
                     we know that there is an OH group present in phen.pdf                     we know that there is an OH group present in phen.pdf
we know that there is an OH group present in phen.pdf
 
systems T and P are different from the reservoi.pdf
                     systems T and P are different from the reservoi.pdf                     systems T and P are different from the reservoi.pdf
systems T and P are different from the reservoi.pdf
 
Since X represents the solid phase, Y represents .pdf
                     Since X represents the solid phase, Y represents .pdf                     Since X represents the solid phase, Y represents .pdf
Since X represents the solid phase, Y represents .pdf
 
Pb^2+ may be present. .pdf
                     Pb^2+ may be present.                            .pdf                     Pb^2+ may be present.                            .pdf
Pb^2+ may be present. .pdf
 
P inversly proportional to 1V so answer is C .pdf
                     P inversly proportional to 1V so answer is C    .pdf                     P inversly proportional to 1V so answer is C    .pdf
P inversly proportional to 1V so answer is C .pdf
 
nutrinos are the smallest part of an atom. NOTE-.pdf
                     nutrinos are the smallest part of an atom. NOTE-.pdf                     nutrinos are the smallest part of an atom. NOTE-.pdf
nutrinos are the smallest part of an atom. NOTE-.pdf
 
Molecular solids are held together in single chai.pdf
                     Molecular solids are held together in single chai.pdf                     Molecular solids are held together in single chai.pdf
Molecular solids are held together in single chai.pdf
 
Liquid crystals (LCs) are a state of matter that .pdf
                     Liquid crystals (LCs) are a state of matter that .pdf                     Liquid crystals (LCs) are a state of matter that .pdf
Liquid crystals (LCs) are a state of matter that .pdf
 
interstellar medium (gas) Solution .pdf
                     interstellar medium (gas) Solution           .pdf                     interstellar medium (gas) Solution           .pdf
interstellar medium (gas) Solution .pdf
 
Hhyd = Hcrystallization + Hsolv Enthalpy of Solv.pdf
                     Hhyd = Hcrystallization + Hsolv  Enthalpy of Solv.pdf                     Hhyd = Hcrystallization + Hsolv  Enthalpy of Solv.pdf
Hhyd = Hcrystallization + Hsolv Enthalpy of Solv.pdf
 
The answer is (b) the condensation of steam to liiquid water.The e.pdf
The answer is (b) the condensation of steam to liiquid water.The e.pdfThe answer is (b) the condensation of steam to liiquid water.The e.pdf
The answer is (b) the condensation of steam to liiquid water.The e.pdf
 
XML Extensiable Markup LanguageHTML Hypertext Markup LanguageD.pdf
XML Extensiable Markup LanguageHTML Hypertext Markup LanguageD.pdfXML Extensiable Markup LanguageHTML Hypertext Markup LanguageD.pdf
XML Extensiable Markup LanguageHTML Hypertext Markup LanguageD.pdf
 
The Data recovery is of two types …One method is by using a softwa.pdf
The Data recovery is of two types …One method is by using a softwa.pdfThe Data recovery is of two types …One method is by using a softwa.pdf
The Data recovery is of two types …One method is by using a softwa.pdf
 
Thanks anon101. D is correctSolutionThanks anon101. D is corre.pdf
Thanks anon101. D is correctSolutionThanks anon101. D is corre.pdfThanks anon101. D is correctSolutionThanks anon101. D is corre.pdf
Thanks anon101. D is correctSolutionThanks anon101. D is corre.pdf
 
Reverse EngineeringReverse engineering is also a back engineering .pdf
Reverse EngineeringReverse engineering is also a back engineering .pdfReverse EngineeringReverse engineering is also a back engineering .pdf
Reverse EngineeringReverse engineering is also a back engineering .pdf
 
Quantum mechanics predicts the existence of what are usually called .pdf
Quantum mechanics predicts the existence of what are usually called .pdfQuantum mechanics predicts the existence of what are usually called .pdf
Quantum mechanics predicts the existence of what are usually called .pdf
 
Program Educational Objectives • To create competencies and opportun.pdf
Program Educational Objectives • To create competencies and opportun.pdfProgram Educational Objectives • To create competencies and opportun.pdf
Program Educational Objectives • To create competencies and opportun.pdf
 
P2O5 removes H2O from Alcohol to form Alkene O of Alcohol gives it.pdf
P2O5 removes H2O from Alcohol to form Alkene O of Alcohol gives it.pdfP2O5 removes H2O from Alcohol to form Alkene O of Alcohol gives it.pdf
P2O5 removes H2O from Alcohol to form Alkene O of Alcohol gives it.pdf
 
cant understand a thing .pdf
                     cant understand a thing                          .pdf                     cant understand a thing                          .pdf
cant understand a thing .pdf
 
Japanese colonial design in china korea and mongolia create an image.pdf
Japanese colonial design in china korea and mongolia create an image.pdfJapanese colonial design in china korea and mongolia create an image.pdf
Japanese colonial design in china korea and mongolia create an image.pdf
 

Recently uploaded

80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxakanksha16arora
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use CasesTechSoup
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfNirmal Dwivedi
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 

Recently uploaded (20)

80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 

StudentData.javaimport java.util.Scanner; public class Student.pdf

  • 1. StudentData.java import java.util.Scanner; public class StudentData { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int totalStudents = 0; int maleCount = 0, femaleCount = 0, minorCount = 0, adultCount = 0, seniorCount = 0; while(true){ System.out.println("Do you ant to add a student (n to stop):"); char ch = scan.next().charAt(0); if(ch == 'n' || ch == 'N'){ break; } else{ System.out.println("Enter the student gender (male or female)"); String gender = scan.next(); if(gender.equalsIgnoreCase("male")){ maleCount++; } else{ femaleCount++; } System.out.println("Enter student age:"); int age = scan.nextInt(); if(age <= 18){ minorCount++; } else if(age >=19 && age <= 65){ adultCount++; } else{ seniorCount++; }
  • 2. } } totalStudents = maleCount + femaleCount; System.out.println("Total Students: "+totalStudents); System.out.println("Male: "+maleCount); System.out.println("Female: "+femaleCount); System.out.println("Minor: "+minorCount); System.out.println("Adult: "+adultCount); System.out.println("Senior: "+seniorCount); String s = (maleCount >= femaleCount)? "Students are mre males":"Students are more females"; System.out.println(s); } } Output: Do you ant to add a student (n to stop): y Enter the student gender (male or female) male Enter student age: 44 Do you ant to add a student (n to stop): y Enter the student gender (male or female) male Enter student age: 77 Do you ant to add a student (n to stop): y Enter the student gender (male or female) male Enter student age: 12 Do you ant to add a student (n to stop): yy Enter the student gender (male or female)
  • 3. female Enter student age: 55 Do you ant to add a student (n to stop): y Enter the student gender (male or female) female Enter student age: 33 Do you ant to add a student (n to stop): n Total Students: 5 Male: 3 Female: 2 Minor: 1 Adult: 3 Senior: 1 Students are mre males Solution StudentData.java import java.util.Scanner; public class StudentData { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int totalStudents = 0; int maleCount = 0, femaleCount = 0, minorCount = 0, adultCount = 0, seniorCount = 0; while(true){ System.out.println("Do you ant to add a student (n to stop):"); char ch = scan.next().charAt(0); if(ch == 'n' || ch == 'N'){ break; }
  • 4. else{ System.out.println("Enter the student gender (male or female)"); String gender = scan.next(); if(gender.equalsIgnoreCase("male")){ maleCount++; } else{ femaleCount++; } System.out.println("Enter student age:"); int age = scan.nextInt(); if(age <= 18){ minorCount++; } else if(age >=19 && age <= 65){ adultCount++; } else{ seniorCount++; } } } totalStudents = maleCount + femaleCount; System.out.println("Total Students: "+totalStudents); System.out.println("Male: "+maleCount); System.out.println("Female: "+femaleCount); System.out.println("Minor: "+minorCount); System.out.println("Adult: "+adultCount); System.out.println("Senior: "+seniorCount); String s = (maleCount >= femaleCount)? "Students are mre males":"Students are more females"; System.out.println(s); } } Output: Do you ant to add a student (n to stop):
  • 5. y Enter the student gender (male or female) male Enter student age: 44 Do you ant to add a student (n to stop): y Enter the student gender (male or female) male Enter student age: 77 Do you ant to add a student (n to stop): y Enter the student gender (male or female) male Enter student age: 12 Do you ant to add a student (n to stop): yy Enter the student gender (male or female) female Enter student age: 55 Do you ant to add a student (n to stop): y Enter the student gender (male or female) female Enter student age: 33 Do you ant to add a student (n to stop): n Total Students: 5 Male: 3 Female: 2 Minor: 1 Adult: 3