generate a Student ID Card.
Generate a Student ID Card.
Desired Output:
Problem Statement: Write a Java program that will take user input and print his Name, Age, Blood Group and also his Group to which he belongs to in the school.
Approach: 1. Write the code for user input
• Initialize class Scanner
• Ask for Student’s name and store it in String variable
• Ask for Student’s age and store it in Integer variable
• Ask for Student’s blood group and store it in String variable
JAVA Code.
package com.company; import java.util.Scanner; public class Main { public static void main(String[] args) { String Yourgroup = "group"; System.out.println("Enter Name: "); Scanner name = new Scanner(System.in); String urname = name.nextLine(); System.out.println("Age: "); Scanner Age = new Scanner(System.in); int urage = Integer.parseInt(Age.nextLine()); if( urage >= 20) { Yourgroup = "RED"; } else if (urage>=15 && urage<20) { Yourgroup = "BLUE"; } else if (urage>=10 && urage<15) { Yourgroup = "YELLOW"; } System.out.println("Blood groop: "); Scanner Bloodgroup = new Scanner(System.in); String urBloodgroup = Bloodgroup.nextLine(); System.out.println(); System.out.println("----------------------"); System.out.println("Name: " + urname); System.out.println("Age: " + urage); System.out.println("Blood group: " + urBloodgroup); System.out.println("----------------------"); System.out.println("Your group: " + Yourgroup); System.out.println("----------------------"); } }
Please give the output for this
ReplyDeletebro when will google put add on your website
ReplyDeletepackage code is missing
ReplyDelete