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...
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.
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
Using Java, write a program named MyAngles that will prompt the user for the measure of...
Using Java, write a program named MyAngles that will prompt the user for the measure of the three sides of a triangle and then reports the measurement of each interior angle of the triangle and the area of the triangle.
Write a short, cohesive java program in jGrasp that interacts with the user and does the...
Write a short, cohesive java program in jGrasp that interacts with the user and does the following: create at least 2 double variables create at least 1 constant get at least 1 string input from the user get at least 1 int/double input from the user include both, incorporating the input you got from the user: 1 multiway if-else with at least 3 "else if" 1 nested if Your program should combine all of these into one cohesive, interactive program...
C++ Write a program that asks a teacher to input a student’s first name, last name,...
C++ Write a program that asks a teacher to input a student’s first name, last name, and four test scores. The program should find the average of the four test scores and should then write the following information to a file named “students.txt” last_name first_name average A student's first name of “XX” should be used as a sentinel value and no numeric grades less than 0 or greater than 100 should be accepted.  The program should then read the information in...
jgrasp environment, java write a complete program that calculates a restaurant bill. Prompt the user for...
jgrasp environment, java write a complete program that calculates a restaurant bill. Prompt the user for the check amount, then ask the user what type of tipp they would like to leave: the choices are 1 for good tip (20%), 2 for an average tip (15%), or 3 for poor tip (10%). Use their input and an if-else to calculate the tip amount. Then calculate and output the final bill: check+tip print out the bill, exactly as shown (print the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT