What's new

Help Patulong po ng java problem ko

kazeroth123

Honorary Poster
Joined
Dec 2, 2017
Posts
105
Solutions
5
Reaction
19
Points
145
Age
24
Create a Java program that accepts a Person's information.

Enter your first name: Christian
Enter your middle initial: L
Enter your last name: Bandoquillo
Enter your Birthdate: January 3, 1997
Enter the number of people in your household: 3
Enter your annual salary: 999,999.00
Enter your gender: Male
Enter your address: Davao City

Output
Welcome, Mr. Christian L Bandoquillo to our system. Your birthdate is January 3, 1997, and you are 24 years old, your gender is male and you reside in Davao City. The total number of people in your household is 3 and your annual salary is Php 999,999.00.

MY CODE:

import java.util.Scanner;
public class Activity2 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter your first name: ");
String inputFName = input.nextLine();
System.out.print("Enter your middle initial: ");
String inputMI = input.nextLine();
System.out.print("Enter your last name: ");
String inputLName = input.nextLine();
System.out.print("Enter your Birthdate: ");
String inputBDay = input.nextLine();
System.out.print("Enter the number of people in your household: ");
int inputPIYH = input.nextInt();
System.out.print("Enter your annual salary: ");
double inputASalary = input.nextDouble();
//Naskiskip po yung gender, ano po rason bakit ganon?
System.out.print("Enter your gender: ");
String inputGender = input.nextLine();
System.out.print("Enter your address: ");
String inputAddress = input.nextLine();
String FullName = inputFName + " " + inputMI + " " + inputLName;
// Code para mahanap yung age using birthday input
int Age = 21;
System.out.println("Welcome, "+FullName+" to our system. Your birthdate is "+inputBDay+", and you are "+Age+" years old, your gender is "+inputGender+" and you reside in "+inputAddress+". The total number of people in your household is "+inputPIYH+" and your annual salary is Php "+inputASalary+".");
}
}



Maraming Salamat po in advance kung sino man makatulong 🙏
 
Last edited:
ito problem lods nasa post..
You do not have permission to view the full content of this post. Log in or register now.

sabi di daw kinukuha ng double or int ang string character kasama na dun ang enter kaya napupunta dun sa next scan yung enter na nag reresulta sa no value..

then dyan sa date calculator, e seperate mo yung taon sa month at day, kasi dapat
2022 - year of birth
dun mo makukuha ang taon ng tao.
ex. 2022-2000 =22.

then minus mo nalang kung mga late sya pinanganak like if december then sa december pa sya mag 22 years old.
 
//Naskiskip po yung gender, ano po rason bakit ganon?

because of the String Buffer. after ng input ng double lagay ka lang ng

input.next()

para mag reset ang string buffer

//Naskiskip po yung gender, ano po rason bakit ganon?

because of the String Buffer. after ng input ng double lagay ka lang ng

input.next()

para mag reset ang string buffer
 

Similar threads

Back
Top