Answer to Question #314946 in Java | JSP | JSF for Donny

Question #314946

Write an application for a lawn-mowing service. The lawn-mowing season lasts 20 weeks. The weekly fee for mowing a lot under 4,000 square feet is R25. The fee for a lot that is 4,000 square feet or more, but under 6,000 square feet, is R35 per week. The fee for a lot that is 6,000 square feet or over is R50 per week. Prompt the user for the length and width of a lawn USING JOPTIONPANE, and then display the weekly mowing fee USING JOPTIONPANE , as well as the 20-week seasonal fee. Save the file as Lawn.java.

Marks allocation 

1. The use of class and object - 10

2. The use of JOption for input -10

3. The use of JOption for output-10

4. correct out -10

 


1
Expert's answer
2022-03-21T06:49:51-0400
import javax.swing.JOptionPane;
public class Lawn {


    public void Calcul(double leng, double wig){
        double squad = leng * wig;
        double weekCost, seasonCost;
        if(squad < 4000){
            weekCost = 25;
        } else if(squad >= 4000 & squad < 6000){
            weekCost = 35;
        } else{
            weekCost = 50;
        }
        seasonCost = weekCost * 20;
        String rez = "The weekly lawn mowing fee is: " + weekCost + "\nThe seasonal lawn mowing fee is: " + seasonCost;
        JOptionPane.showMessageDialog(null, rez);
    }

    public static void main(String[] args) {

        Lawn law = new Lawn();

        String lenghtS = JOptionPane.showInputDialog("Enter");
        double lenght = Double.parseDouble(lenghtS);

        String widthS = JOptionPane.showInputDialog("Enter");
        double width = Double.parseDouble(widthS);

        law.Calcul(lenght, width);

    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS