Question

In: Computer Science

Using jGRASP, write a Java program named LastnameFirstname10.java, using your last name and your first name,...

  • Using jGRASP, write a Java program named LastnameFirstname10.java, using your last name and your first name, that does the following:
    • Create two arrays that will hold related information.
      • You can choose any information to store, but here are some examples:
        • an array that holds a person's name and an array that hold's their phone number
        • an array that holds a pet's name and an array that holds what type of animal that pet is
        • an array that holds a student's name and an array that holds what their grade is.
    • Allow a user to fill in the information for the array. Use a loop.
      • Note: Limit the size of your array. Make it at least size 3, but no larger than 10.
    • Print out the contents of both arrays so that the information in the different arrays are presented in a coherent manner.
      • Examples:
        • Nikki's phone number is: 455-0123
          Ed's phone number is: 455-0987
          Blanca's phone number is: 455-3456
        • Snoopy is a pet dog
          Garfield is a pet cat
          Pudge is a pet fish
        • William : B
          Mike : C
          Pete : A
    • Use loops to print out the contents of the arrays.
    • Note: You can make your arrays hold whatever information you want. You don't need to follow the examples. Be creative as you wish! :)
  • Your program MUST:
    • Actively use in-line comments stating what each section of code does.
    • Use try/catch if, and only if, necessary.
    • Begin storing data in the first box of the array - not the second.
  • Your program must conform to the Java coding standards

Solutions

Expert Solution

Source Code:

Output:

Code in text format (See above images of code for indentation):

import java.util.*;

/*class definition*/

public class LastnameFirstname10

{

    /*main method*/

    public static void main(String[] args)

    {

        /*Scanner object to read data from the user*/

        Scanner read=new Scanner(System.in);

        /*declare two arrays*/

        String[] names=new String[5];

        String[] grades=new String[5];

        /*read data into arrays*/

        System.out.println("Enter student names and their grades:");

        for(int i=0;i<5;i++)

        {

            /*read name from user and store it in names array*/

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

            names[i]=read.nextLine();

            /*read grade from user and store it in grades array*/

            System.out.print("Grade: ");

            grades[i]=read.nextLine();

        }

        /*print contents of array*/

        System.out.println("Name\tGrade");

        for(int i=0;i<5;i++)

            System.out.println(names[i]+":  "+grades[i]);

    }

}


Related Solutions

Using jGRASP, write a Java program named LastnameFirstname09.java, using your last name and your first name,...
Using jGRASP, write a Java program named LastnameFirstname09.java, using your last name and your first name, that does the following: Declare an array reference variable called myFavoriteSnacks for an array of String type. Create the array so that it is able to hold 10 elements - no more, no less. Fill the array by having each array element contain a string stating one of your favorite foods/snacks. Note: Only write the name of the snack, NO numbers (i.e. Do not...
Using jGRASP, write a Java program named LastnameFirstname11.java, using your last name and your first name,...
Using jGRASP, write a Java program named LastnameFirstname11.java, using your last name and your first name, that does the following: Defines a method called generateNums. This method will create an array of size x, fill it with random numbers between y and z, then return the array. When you call the method, you must specify the size of the array (x), the beginning of your random number range (y), and the ending of your random number range (z). Defines a...
jgrasp environment, java write a complete program that prompts the user to enter their first name,...
jgrasp environment, java write a complete program that prompts the user to enter their first name, middle name, and last name (separately). print out thier name and initials, exactly as shown: your name is: John Paul Chavez your initials are: J. P. C. use string method chartAt() to extract the first (zero-th) character from a name(the name is a string type): username.charAt(0). thank you.
Write a C++ Program to print the first letter of your first and last name using...
Write a C++ Program to print the first letter of your first and last name using stars. Note: 1) Using nested For Loop 2) The number of lines is given by user. 3) Using one Outer loop to print your letters. 4) Print the letters beside each other.
Write a C++ Program to print the first letter of your first and last name using...
Write a C++ Program to print the first letter of your first and last name using stars. Note: 1) Using nested For Loop 2) The number of lines is given by user. 3) Using one Outer loop to print your letters. 4) Print the letters beside each other
java programming write a program with arrays to ask the first name, last name, middle initial,...
java programming write a program with arrays to ask the first name, last name, middle initial, IDnumber and 3 test scores of 10 students. calculate the average of the 3 test scores. show the highest class average and the lowest class average. also show the average of the whole class. please use basic codes and arrays with loops the out put should look like this: sample output first name middle initial last name    ID    test score1 test score2...
Write a Java program using jGRASP directions are as follows: Uses a while loop to print...
Write a Java program using jGRASP directions are as follows: Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop to print the numbers from 42 - 56. Uses a for loop to print the numbers from 87 - 95. Asks the user for 2 numbers. Uses a loop to print all numbers between the given numbers, inclusive. Note: Consider that your user's second number can be lower! (see example below) Note: Also consider...
Write a class named Person with data attributes for a person’s first name, last name, and...
Write a class named Person with data attributes for a person’s first name, last name, and telephone number. Next, write a class named Customer that is a subclass of the Person class. The Customer class should have a data attribute for a customer number and a Boolean data attribute indicating whether the customer wishes to be on a calling list. Demonstrate an instance of the Customer class in a simple program. Using python
Write a program named filemaker.py in python that will be used to store the first name...
Write a program named filemaker.py in python that will be used to store the first name and age of some friends in a text file named friends.txt. The program must use a while loop that prompts the user to enter the first name and age of each friend. Each of these entries should be written to its own line in the text file (2 lines of data per friend). The while loop should repeat until the user presses Enter (Return...
write program in java Create a class named PersonalDetails with the fields name and address. The...
write program in java Create a class named PersonalDetails with the fields name and address. The class should have a parameterized constructor and get method for each field.  Create a class named Student with the fields ID, PersonalDetails object, major and GPA. The class should have a parameterized constructor and get method for each field. Create an application/class named StudentApp that declare Student object. Prompts (GUI input) the user for student details including ID, name, address, major and GPA....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT