Question

Please answer all the questions and I don't want work for another person. do it in jaf project.

5.6 (Conversion from m to kilometers) Write a program that displays the following two tables side by side: Miles Miles Kilometers Kilometers 1.609 20 12.430 15.538 3.218 25 37.290 14.481 60 I 65 40.398 10 16.090 5.8 (Find the highest score) Write a program that prompts the user to enter the number of students and each students name and score, and finally displays the name of the student with the highest score. Use the next method in the Scanner class to read a name rather using the nextLine method

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


public class MilesToKilometers
{
   public static void main(String[] args)
   {
       System.out.printf("%-12s%-12s %s   %-12s%-12s\n",
               "Miles", "Kilometers", "|", "Kilometers", "Miles");
       int miles = 1;
       int kilometers = 20;
       while (miles <= 10)
       {
           System.out.printf("%-12s%-12.3f %s   %-12d%-12.3f\n",
                   miles, (double)miles * 1.609, "|",
                   kilometers, (double)kilometers / 1.609);
           miles++;
           kilometers = kilometers + 5;
       }
   }
}


Problems@Javadoc Declaration Console <terminated> MilesToKilometers [Java Application] C:\Program Files Javaljrel.6.0_011binl

import java.util.Scanner;
import java.util.Arrays;

public class FindTheHighestScore {

  
   public static void main(String[] args)
   {
       // input
       String[] names;
       double[] scores;
       Scanner input = new Scanner(System.in);
       int students;
       double highScore;
       int[] scoreIndexes = new int[1];
      
       System.out.print("How many students are there?: ");
       students = input.nextInt();
       input.nextLine();
       names = new String[students];
       scores = new double[students];
      
       // processing
           // Filling in arrays with data
       for(int i = 0; i < students; i++)
       {
           System.out.print("What is the student's name?: ");
           names[i] = input.nextLine();
           System.out.print("What is the student's score?: ");
           scores[i] = input.nextDouble();
           input.nextLine();
       }
      
       highScore = scores[0];
       scoreIndexes[0] = 0;
           // Finding highest score/s
       for (int i = 1; i < names.length; i++)
       {
           // find if it's a high, same, or low score
               // If high, set highScore, reset scoreIndexes and set scoreIndexes[0] to i.
           if (highScore < scores[i])
           {
               highScore = scores[i];
               // integerArray = Arrays.copyOf(integerArray, i + 1); notes.
               scoreIndexes = Arrays.copyOf(scoreIndexes, 1);
               scoreIndexes[0] = i;
           }
               // If same, increase scoreIndexes size and set new int at end of array to i.
           else if (highScore == scores[i])
           {
               scoreIndexes = Arrays.copyOf(scoreIndexes, scoreIndexes.length + 1);
               scoreIndexes[scoreIndexes.length - 1] = i;
           }
               // If low, continue (aka do nothing here).
           else ;
       }
      
       // output
       System.out.printf("%d people have the high score.\n", scoreIndexes.length);
       System.out.printf(
               "The high score was %f\nThe names of the students with the high score are...\n", highScore);
       for (int i = 0; i < scoreIndexes.length; i++)
           System.out.printf("%s\n", names[scoreIndexes[i]]);
      
       input.close();
   }

}


Problems JavadocDeclaration Console <terminated> _FindTheHighestScore [Java Application] C:Program Filesarel.6.0_01\binljavaw


public class ASCIICharacterTable
{
   public static void main(String[] args)
   {
       // Decleare int outputCount and initialize to 0;
       // Create character i intialize at '!' and stop loop at '~'
       // Display character then space and increment outputCount
       // If outputCount % 10 == 0 then println

       int outputCount = 0;
       for (char i = '!'; i <= '~'; i++)
       {
           System.out.printf("%c ", i);
           ++outputCount;
           if (outputCount % 10 == 0)
               System.out.println();
       }
   }
}


Problems Javadoc@ Declaration Console X <terminated> ASCIICharacterTable [Java Application CProgram FilesJavajre1.6.0_01\bin

//package chapter_5;

import java.util.Scanner;

public class DisplayPyramid
{
   public static void main(String[] args)
   {
       // input
       Scanner input = new Scanner(System.in);
       int number;

       System.out.print("Enter an integer from 1 to 15: ");
       number = input.nextInt();

       // processing and output
       for (int j = 0; j < number; j++)
       {
           for (int i = -number + 1; i < number; i++)
           if (Math.abs(i) <= j)
               System.out.printf("%-3d", Math.abs(i) + 1);
           else
               System.out.printf("   ");
           System.out.println();
       }
       input.close();
   }
}


Add a comment
Know the answer?
Add Answer to:
Please answer all the questions and I don't want work for another person. do it in...
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
  • Please show screenshot outputs and fully functional code for the Java programs. Question 1: Write a...

    Please show screenshot outputs and fully functional code for the Java programs. Question 1: Write a method that computes and returns the area of a square using the following header: public static double area ( double side) Write a main method that prompts the user to enter the side of a square, calls the area method then displays the area. Question 1a: Write a method that converts miles to kilometers using the following header: public static double convertToKilometers (double miles)...

  • CIS 22A C++ Project Exam Statistics Here is what your program will do: first it welcomes...

    CIS 22A C++ Project Exam Statistics Here is what your program will do: first it welcomes the user and displays the purpose of the program. It then prompts the user to enter the name of an input file (such as scores.txt). Assume the file contains the scores of the final exams; each score is preceded by a 5 characters student id. Create the input file: copy and paste the following data into a new text file named scores.txt DH232 89...

  • I need #5 done i cant seem to understand it. it must be written in c++...

    I need #5 done i cant seem to understand it. it must be written in c++ 4. Numeric Processing Write a program that opens the file "random.txt", reads all the numbers from the file, and calculates and displays the following: a. The number of numbers in the file. b. The sum of all the numbers in the file (a running total) c. The average of all the numbers in the file numFile.cpp Notes: Display the average of the numbers showing...

  • please write psedocodes for all of the questions and an algorithm for 2. no coding is...

    please write psedocodes for all of the questions and an algorithm for 2. no coding is required . FIUJELI 95 PIOL 1. (Geometry: Area of a Pentagon) Write a C# program that prompts the user to enter the length from the center of a pentagon to a vertex and computes the area of the pentagon, as shown in the following figure. The formula for computing the area of a pentagon is Area = 2 , where s is the length...

  • Within DrJava, create a class called StudentQuizScores and do the following using a do-while loop. 1....

    Within DrJava, create a class called StudentQuizScores and do the following using a do-while loop. 1. You program will read in a student’s first name. The same will be done for the student’s last name. Your program will use respective methods (described below) to accomplish this. 2. Your program will then read in three quiz scores, respectively. This should be done by using the same method three times. This method is described below. 3. Your program will then calculate the...

  • *MYST BE I NJAVA* *PLEASE INCORPORATE ALL OF STRING METHODS AND SCANNER METHOD LISTED IN THE...

    *MYST BE I NJAVA* *PLEASE INCORPORATE ALL OF STRING METHODS AND SCANNER METHOD LISTED IN THE DIRECTIONS BELOW* Write a Java class that takes a full name (first and last) as inputted by the user, and outputs the initials. Call the class Initials. The first and last names should be entered on the same input line i.e. there should be only one input to your program. For example, if the name is Jane Doe, the initials outputted will be J...

  • I've done all questions except question 6. how do I do this? please help. code needs...

    I've done all questions except question 6. how do I do this? please help. code needs to be java 1. You need to be able to open and read the text files that have been provided for the project. Write a Java program that reads the driver.txt file and displays each data value for each line from the file to the screen in the following format: Licence Number: Licence Class: First Name: Last Name: Address: Suburb: Postcode: Demerit Points: Licence...

  • PLEASE DO IN PYTHON Program 2: Design (pseudocode) and implement (source code) a program (name it...

    PLEASE DO IN PYTHON Program 2: Design (pseudocode) and implement (source code) a program (name it FeetMeters) to display a conversion tables for feet and meter as show below. Document your code and properly. Feet Meter 1.0 0.305 2.0 0.610 3.0 0.915 . . . . . . 19.0 5.7.95 20.0 6.100 Meter Feet 1.0 3.279 2.0 6.558 3.0 9.837 . . . . . . 19.0 62.301 20.0 65.574 The program defines the following methods: Method feetToMeter() converts from...

  • I want to know how to do this assignment!!! Help me please~ The first part of...

    I want to know how to do this assignment!!! Help me please~ The first part of your program should do the following: • Ask the user type of test they took. o (ACT or SAT) • If they said ACT then ask them their score o If their ACT score was between 0 and 7 say "Needs Work" o If their ACT score was between 10 and 20 say "Acceptable" o If they ACT score was above 20 say "Above...

  • ANY HELP PLEASE. PLEASE READ THE WHOLE INSTRUCTION THANK YOU Write a program GS.java that will...

    ANY HELP PLEASE. PLEASE READ THE WHOLE INSTRUCTION THANK YOU Write a program GS.java that will be responsible for reading in the names and grades for a group of students, then reporting some statistics about those grades. The statistics to be gathered are the number of scores entered, the highest score and the name(s) of the student(s) who earned that score, the lowest score and the name(s) of the student(s) who earned that score, and the average score for 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