使用selenium和java获取div的总数

一家油漆公司确定,每 115 平方英尺的墙面空间需要一加仑油漆和八小时的劳动力。该公司每小时人工费为 18.00 美元。编写一个程序,允许用户输入要粉刷的房间数量以及每加仑油漆的价格。它还应该询问每个房间的墙壁空间的平方英尺。该程序应具有返回以下数据的方法: • 所需油漆的加仑数 • 所需的人工时间 • 油漆成本 • 人工费用 • 油漆工作的总成本 然后应显示以下数据:屏幕。


我还没有解决这个问题的劳动部分,但由于 PaintNeeded 变量,我无法打印 costOfPaint() 。


我尝试将 costOfPaint 方法中的语句写入到 main 方法中,并且它有效。但这并没有帮助,因为我需要方法来做到这一点。我知道我的问题与 PaintNeeded 变量有关,我只是不确定如何解决这个问题。


公共类主要{


public static double paintRequired(double totalSquareFeet){


    double paintNeeded = totalSquareFeet / 115;

    return paintNeeded;


                                                          }


public static double costOfPaint(double paintNeeded, double costOfPaint){

    double paintCost = paintNeeded * costOfPaint;

    return paintCost;

                                                    }



public static void main(String[] args){

    double costOfPaint = 0;

    int totalSquareFeet = 0;

    double paintNeeded = 0;


    Scanner getUserInput = new Scanner(System.in);


    System.out.println("what is the cost of the paint per gallon");

        costOfPaint = getUserInput.nextDouble();

    System.out.println("How many rooms do you need painted");

        int rooms = getUserInput.nextInt();

            for(int i = 1; i <= rooms; i++){

                System.out.println("how many square feet are in room:" + i);

                int roomSquareFeet = getUserInput.nextInt();

                totalSquareFeet = roomSquareFeet + totalSquareFeet;

                                           }


    System.out.println("the amount of paint needed:" + paintRequired(totalSquareFeet) + "gallons");

    System.out.println("the cost of the paint will be: " + costOfPaint(paintNeeded, costOfPaint));


}

}


对于我的绘制成本,我一直得到 0。


慕雪6442864
浏览 66回答 1
1回答

偶然的你

你不改变paintNeeded。总是如此0。paintNeeded&nbsp;=&nbsp;paintRequired(totalSquareFeet); System.out.println("the&nbsp;amount&nbsp;of&nbsp;paint&nbsp;needed:&nbsp;"&nbsp;+&nbsp;paintNeeded&nbsp;+&nbsp;"&nbsp;gallons"); System.out.println("the&nbsp;cost&nbsp;of&nbsp;the&nbsp;paint&nbsp;will&nbsp;be:&nbsp;"&nbsp;+&nbsp;costOfPaint(paintNeeded,&nbsp;costOfPaint));
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java