英尺到秒 - 不能增加秒数 Java

Feet to Seconds - Can't increment seconds Java

我正在创建一个程序,如果用户正在发短信,它将显示他们在开车时行驶了多少英尺。

到目前为止,这就是我得到的, 如果用户以 60 MPH 的速度行驶,一秒钟的分心将传播 88 英尺。 如果用户以 20MPH 的速度行驶,一秒钟的分心将传播 29 英尺。等等。

我无法弄清楚的问题是,如果我在此方法上增加秒数 c.SetHourstoSeconds(1)。我的程序开始除法,而不是乘法。我创造了新方法,但到目前为止我完全不知道如何让它发挥作用。提前致谢。

  public class App {

 public App() {
    //  TODO Auto-generated constructor stub
}

public static void main(String[] args) {
    // TODO Auto-generated method stub
    Conversions c = new Conversions();



    c.SetMilestoFeet(60);

    c.SetHourstoSeconds(1);


    System.out.println("Total feet travel " + c.Total() + "ft");
   }
  }

public class 转化 {

static int Milestofeet =0;
static int MinutestoSeconds =0;

public Conversions() {

}



public static void SetMilestoFeet(int x)
{

    Milestofeet = x * 5280;




}

public static void SetHourstoSeconds(int hr)
{
    int hourstoMinutes = hr * 60;
     MinutestoSeconds = hourstoMinutes * 60;

        System.out.println("***********" + hr);


}

public static int Sec()
{

    return MinutestoSeconds;
}

public static int Feet()
{

    return Milestofeet;
}


public int  Total()
{
    System.out.print(Milestofeet + "   ___" + MinutestoSeconds + "______=" );

    return (Feet()/Sec());

}

}

你让这个太难了

/**
 * Calculate distance traveled per second of distraction
 * User: mduffy
 * Date: 8/25/2016
 * Time: 2:40 PM
 * @link 
 */
public class DistractionDistanceCalculator {

    public static final int FEET_PER_MILE = 5280;
    public static final int SECONDS_PER_HOUR = 3600;

    public static void main(String[] args) {
        double mph = (args.length > 0) ? Double.parseDouble(args[0]) : 60.0;
        double distractionSeconds = (args.length > 1) ? Double.parseDouble(args[1]) : 1.0;
        double distance = calculateDistractionDistance(mph, distractionSeconds);
        System.out.println(String.format("You will travel %10.3f feet if you are distracted for %10.3f distractionSeconds at %10.3f mph", distance, distractionSeconds, mph));
    }

    private DistractionDistanceCalculator() {
    }

    public static double calculateDistractionDistance(double mph, double distractionSeconds) {
        if (mph < 0.0) throw new IllegalArgumentException("Speed must be positive");
        if (distractionSeconds < 0.0) throw new IllegalArgumentException("Distraction seconds must be positive");
        return mph*FEET_PER_MILE/SECONDS_PER_HOUR*distractionSeconds;
    }
}