Question: How can I redo this so that it doesn't have static in front of double, int, and Scanner under defining variables? import java.util.*; public

How can I redo this so that it doesn't have "static" in front of double, int, and Scanner under defining variables? 

 

import java.util.*;

public class chpt6 {
//Declaring global variables
    static double speed, time;
    static int height;
 static Scanner input = new Scanner(System.in);
 
//This method computes for the height of the ball
 public static double calcBallHeight(int height, double speed, double time) {
  double ballHeight;
  ballHeight = -(16*time*time) + (speed*time) + height;
  return ballHeight;
 }
 
 public static void main(String[] args) {

//Prompts user to input
  System.out.print("Enter the height of the building in feet as an integer: ");
  height = input.nextInt();
  System.out.print("Enter the initial speed of the ball in ft/sec as a double: ");
  speed = input.nextDouble();
  System.out.print("Enter the flight time of the ball as a double: ");
  time = input.nextDouble();
 
//Calls the method to compute for the height of ball
  double ballHeight = calcBallHeight(height,speed,time);
 
//Prints out the result
  System.out.printf("The ball will be %.2f feet above the ground after %.2f seconds of flight time.", ballHeight, time);
 }
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

You can simply remove the static keyword from the variable declarations under Defining variables Her... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!