I am having trouble writing the below java application.

Here is what i am trying to accomplish

Write a Java program that prompts a user to enter demographic information including year of birth (values 1900-2014), month of birth (values 1-12), day (value of 1-31) of birth, latitude and longitude of home address current grade point average (GPA).

Here is what I have so far.

// Import each required Java class
import java.util.Scanner;

/**
* MY Survey
*/

public class winstoncomptonhw1a {



public static void main(String[] args) {

    // Variables to hold values
    byte year = 0;
    int month = 0;
    float latitude = 0.0f;
    float longitude = 0.0f;

System.out.println("Welcome to My Survey"); 

    // Use the Scanner class to input data from Standard I/O
    Scanner scannerIn = new Scanner(System.in);

    // Prompt the user to enter their Birth Year
    System.out.println("Enter your Birth Year (1900-2014):");

    year = scannerIn.nextByte();

    // Verify the Birth Year
System.out.println("The following Year was entered " + year);

    //Prompt the user to enter their Birth Month
      System.out.println("Enter your Birth month (1-12):");
// the nextInt() method scans the next int value
      month = scannerIn.nextInt();


    // Verify the Birth month was entered
System.out.println("The following month was entered " + month);

    //Prompt the user to enter their day of Birth
    System.out.println("Enter the day of your birth (1-31):");
    // the nextInt() method scans the next int value
    month = scannerIn.nextInt();

    // Prompt the user to enter the latitude of their address
    System.out.println("Enter the latitude of your address:");
    latitude = scannerIn.nextFloat();

    // Prompt the user to enter the longitude of their address
    System.out.println("Enter the longitude of your address:");
    longitude = scannerIn.nextFloat();

    // Prompt the User to enter their current GPA
    System.out.println("Enter your current GPA (0.0-4.0):");

    // Display all results to Standard Output
System.out.println("*******Thank you for completing our our survey***********");

System.out.println("You have entered the following data:");

    System.out.println("Birth Year is:" + Year);

    System.out.println("Birth Month is :" + Birth Month);

    System.out.println("Birth Day is :" + day);

    System.out.println("latitude is :" + latitude);

    System.out.println("longitude is :" + longitude);

    System.out.println("GPA is :" + GPA);

}



}

Recommended Answers

All 3 Replies

And what exactly is it you are having trouble with at this point?

Member Avatar for iamthwee

This program seems pointless unless you're supposed to validate the input?

It's a start at least. Take the input. Print it out to verify what you got. This may be what the teacher of the class wants at this point. So Winston, do you have a problem here?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.