0% found this document useful (0 votes)
429 views2 pages

Java Basics Assignment

This document provides an assignment to write a Java program that takes user input for a student's name, age, and blood group, then prints a student ID card with that information and assigns the student to a group (RED, BLUE, or YELLOW) based on their age. The program should use if/else if statements to determine the group based on the student's age, then output the ID card with their details and assigned group.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
429 views2 pages

Java Basics Assignment

This document provides an assignment to write a Java program that takes user input for a student's name, age, and blood group, then prints a student ID card with that information and assigns the student to a group (RED, BLUE, or YELLOW) based on their age. The program should use if/else if statements to determine the group based on the student's age, then output the ID card with their details and assigned group.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment 1

Hey! Now that you’re familiar with basics of Java programming, let’s write a small java program to
generate a Student ID Card.

——————————————
Name: Sriyank Siddhartha
Age: 25
Blood Group: A+
——————————————
Your group is RED
——————————————

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
• Initialise 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
2. Once you have got all user inputs, it’s time to decide the group to which the student
belongs to. Let's divide the students into three groups: RED, BLUE and YELLOW. A
group for a student is decided based on his age.
• RED: If the age of a student is greater than or equal to 20 then he belongs to RED
group
• BLUE: If the age of a student is greater than or equal to 15 but smaller than 20 then he
belongs to BLUE group.
• YELLOW: If the age of a student is greater than or equal to 10 but smaller than 15 then
he belongs to YELLOW group
You need to use IF-ELSE-IF Ladder statements to decide the group for the student
based on his age.
3. One you have got all the attributes such as name, age, blood group and group name,
you need to print out the Student ID Card that should look similar the desired output.

Hints:
• To draw dashed lines use hyphen symbol in the print statement

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy