Question

Create a new Java class called AverageWeight. Create two arrays: an array to hold 3 different names and an array to hold theiWe use bluej for our JAVA class. If you can help me id greatly appreciate it.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;
class AverageWeight //creating a class AverageWeight
{
   public static void main(String[] args)
   {
       String names[]=new String[3]; //creates string array with size 3 to stores names
       float weights[]=new float[3]; //creates float array with size 3 to stores weights
       for(int i=0;i<3;i++)
       {   Scanner sc =new Scanner(System.in);
           System.out.print("Enter Name:");
           names[i]=sc.nextLine(); //taking name from user
           System.out.print("Enter weight:");
           weights[i]=sc.nextFloat(); //taking weight from user
           System.out.println(); //prints new line
       }
       System.out.print("Name\t\tWeight\n"); //\t for tab space
       System.out.print("----------------------\n");
       float sum=0;
       for(int i=0;i<3;i++)
       {
           System.out.print(names[i]+"\t\t"+weights[i]+"\n"); //prints name and weight of 3 persons
           sum=sum+weights[i]; //sum of 3 weights
       }
       System.out.println();
       System.out.print("Average Weight:"+sum/3); //prints average
   }
}

1 2 3 4 import java.util.*; class AverageWeight //creating a class AverageWeight { public static void main(String[] args) { {Enter Name:himanth Enter weight:54 Enter Name:raj Enter weight:43 Enter Name:roy Enter weight:65 Name Weight himanth raj roy

Add a comment
Know the answer?
Add Answer to:
We use bluej for our JAVA class. If you can help me id greatly appreciate it....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • We are using blueJ for my java class, if you can help me id greatly appreciate...

    We are using blueJ for my java class, if you can help me id greatly appreciate it. Create a new Java class called AverageWeight. Create two arrays: an array to hold 3 different names and an array to hold their weights. Use Scanner to prompt for their name and weight and store in correct array. Compute and print the average of the weights entered using printf command. Use a loop to traverse and print the elements of each array or...

  • We are using blueJ for my java class, if you can help me id greatly appreciate...

    We are using blueJ for my java class, if you can help me id greatly appreciate it. Create a new Java project/class called ChangeUp. Create an empty int array of size 6. Create a method called populateArray that will pass an array, use random class to choose a random index and prompt the user to enter a value, store the value in the array. Create a method called printArray that prints the contents of the array using the for each...

  • We are using blueJ for my java class, if you can help me id greatly appreciate...

    We are using blueJ for my java class, if you can help me id greatly appreciate it. Create a new Java project/class called ChangeUp. Create an empty int array of size 6. Create a method called populateArray that will pass an array, use random class to choose a random index and prompt the user to enter a value, store the value in the array. Create a method called printArray that prints the contents of the array using the for each...

  • We use bluej for our JAVA program. If you can help id greatly appreciate it. Create...

    We use bluej for our JAVA program. If you can help id greatly appreciate it. Create a new Java program called Flip. Write code that creates and populates an array of size 25 with random numbers between 1-50. Print the array. Print array in reverse.

  • We are using blueJ for my java class, if you can help me id greatly appreciate...

    We are using blueJ for my java class, if you can help me id greatly appreciate it. Create a new Java program called Flip. Write code that creates and populates an array of size 25 with random numbers between 1-50. Print the array. Print array in reverse.

  • Hello, can someone please help me correct this code? I greatly appreciate it. 7.16 Ch 7...

    Hello, can someone please help me correct this code? I greatly appreciate it. 7.16 Ch 7 Warm up: People's weights (Lists) (Python 3) (1) Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store all weights in a list. Output the list. (2 pts) Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3] (2) Output the average of the list's elements...

  • Programming in java In this part of this Lab exercise, you will need to create a...

    Programming in java In this part of this Lab exercise, you will need to create a new class named ArrayShiftMult. This class carries out simple manipulation of an array. Then you should add a main method to this class to check that your code does what it is supposed to do. 1. Create a BlueJ project named LAB06 as follows: a. Open the P drive and create a folder named Blue), if it does not exist already. Under this folder,...

  • create java application with the following specifications: -create an employee class with the following attibutes: name...

    create java application with the following specifications: -create an employee class with the following attibutes: name and salary -add constuctor with arguments to initialize the attributes to valid values -write corresponding get and set methods for the attributes -add a method in Employee called verify() that returns true/false and validates that the salary falls in range1,000.00-99,999.99 Add a test application class to allow the user to enter employee information and display output: -using input(either scanner or jOption), allow user to...

  • Create a java class that calculates the various statistics of your favorite quarterback in NFL. If...

    Create a java class that calculates the various statistics of your favorite quarterback in NFL. If you don’t have one, you could use pick Matt Ryan of Atlanta Falcons from his 2015 season. Use either visit nfl.com or their team website for some of the data you would need to complete this assignment. Implement the main method in the class and do the following in the main method Create an appropriate type of array (yards) to store a number of...

  • (JAVA) Use the Pet.java program from the original problem (down below) Compile it. Create a text...

    (JAVA) Use the Pet.java program from the original problem (down below) Compile it. Create a text file named pets10.txt with 10 pets (or use the one below). Store this file in the same folder as your “class” file(s). The format is the same format used in the original homework problem. Each line in the file should contain a pet name (String), a comma, a pet’s age (int) in years, another comma, and a pet’s weight (double) in pounds. Perform the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT