0% found this document useful (0 votes)
78 views6 pages

Student: PANCHO, Ciandra V. Laboratory Activity IT21S2 CITE004

The document contains 5 Java programs that collect user input data about different entities (Student, Company, Employee, Product, User) and output the collected data. Each program uses Scanner to prompt for and input various data fields like name, gender, ID number, etc. and then displays the data in a formatted output at the end.

Uploaded by

CIANDRA PANCHO
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)
78 views6 pages

Student: PANCHO, Ciandra V. Laboratory Activity IT21S2 CITE004

The document contains 5 Java programs that collect user input data about different entities (Student, Company, Employee, Product, User) and output the collected data. Each program uses Scanner to prompt for and input various data fields like name, gender, ID number, etc. and then displays the data in a formatted output at the end.

Uploaded by

CIANDRA PANCHO
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/ 6

PANCHO, Ciandra V.

Laboratory Activity

IT21S2 CITE004

1. Student

package dataStructures;

import java.util.Scanner;

public class Student {


public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.print("Name: ");
String name = scan.nextLine();

System.out.print("Gender: press 1 for Female press 2 for Male ");


byte option = scan.nextByte();

System.out.print("Student ID: ");


int id = scan.nextInt();

System.out.print("GWA: ");
float gwa = scan.nextFloat();

System.out.print("Student Balance: ");


double balance = scan.nextDouble();
scan.close();

System.out.println("\n\nDATA COLLECTED");
System.out.println("NAME: " +name);

switch(option) {
case 1:
System.out.println("GENDER: Female");
case 2:
System.out.println("GENDER: Male");
}

System.out.println("Student ID: "+id);


System.out.println("GWA: "+gwa);
System.out.println("BALANCE: "+balance);

}
Output:

2. Company
package dataStructures;

import java.util.Scanner;

public class Company {


public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.print("Company Name: ");


String name = scan.nextLine();
System.out.print("Location: ");
String location = scan.nextLine();
System.out.print("Contact Info: ");
int num = scan.nextInt();
System.out.print("Number of Users: ");
long users = scan.nextLong();
System.out.print("Networth of the company: ");
double net = scan.nextDouble();
scan.close();

System.out.println("\n\nDATA COLLECTED");
System.out.println("Company Name: "+name);
System.out.println("Contact Info: "+num);
System.out.println("Location: "+location);
System.out.println("Number of users: "+users);
System.out.println("Networth: "+net);
}
}
Output:

3. Employee

package dataStructures;

import java.util.Scanner;

public class Employee {


public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.println("FULL NAME: ");


String name = scan.nextLine();
System.out.println("SCHOOL: ");
String school = scan.nextLine();
System.out.println("Age: ");
byte age = scan.nextByte();
System.out.println("Gender: press 1 for Female press 2 for Male ");
byte option = scan.nextByte();
System.out.println("Contact Number: ");
int num = scan.nextInt();

scan.close();

System.out.println("\n\nDATA COLLECTED");
System.out.println("FULLNAME: "+name);
System.out.println("SCHOOL: "+school);
System.out.println("AGE: "+age);
switch(option) {
case 1:
System.out.println("GENDER: Female");
case 2:
System.out.println("GENDER: Male");
}
System.out.println("NUMBER: "+num);
}

Output:

4. Product

package dataStructures;

import java.util.Scanner;

public class Product {


public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.println("Product Name: ");


String name = scan.nextLine();
System.out.println("Location: ");
String location = scan.nextLine();
System.out.println("Category: ");
String category = scan.nextLine();
System.out.println("Price: ");
double price = scan.nextDouble();
System.out.println("Expiration Date: ");
int date = scan.nextInt();

scan.close();

System.out.println("\n\nDATA COLLECTED");
System.out.println("Product Name: "+name);
System.out.println("Location: "+location);
System.out.println("Category: "+category);
System.out.println("Price: "+price);
System.out.println("Consume Before: "+date);
}

Output:

5. User

package dataStructures;

import java.util.Scanner;

public class User {


public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.print("Username: ");
String name = scan.nextLine();

System.out.print("Password: ");
String pw = scan.nextLine();

System.out.print("Gender: press 1 for Female press 2 for Male ");


byte option = scan.nextByte();

System.out.print("User ID: ");


int id = scan.nextInt();
System.out.print("Mobile: ");
long num = scan.nextLong();

scan.close();

System.out.println("\n\nDATA COLLECTED");
System.out.println("USERNAME: " +name);

switch(option) {
case 1:
System.out.println("Gender: Female");
case 2:
System.out.println("Gender: Male");
}

System.out.println("User ID: "+id);


System.out.println("Mobile: "+num);
System.out.println("Password: *******");

}
}

Output:

You might also like