我必须为我的编程做一个项目 course.This 是我的代码

i have to make a project for my Programming course.This is my code

public class Project1{

    public static void main(String[] args)

    int noOfPhotocopy;
    float totalprice;

    String customer's_name;
    customer's_name = JOptionPane.showInputDialog("Enter customer's name: ");

    String type;
    type = JOptionPane.showInputDialog("Choose type of photocopy: G/C");

    if (type==G){
    noOfPhotocopy = JOptionPane.showInputDialog("Enter no of photocopy: ");

    if (noOfPhotocopy<10){
    totalprice = noOfPhotocopy * 0.10;
    JOptionPane.showMessageDialog(null, "Total price is RM" +totalprice);
    } else if(noOfPhotocopy>=10) {
    totalprice = noOfPhotocopy * 0.05;
    JOptionPane.showMessageDialog(null, "Total price is RM" +totalprice);
    }

    else if (type==C){
    noOfPhotocopy = JOptionPane.showInputDialog("Enter no of photocopy: ");

    if (noOfPhotocopy<10){
    totalprice = noOfPhotocopy * 0.20;
    JOptionPane.showMessageDialog(null, "Total price is RM" +totalprice);
    } else if(noOfPhotocopy>=10) {
    totalprice = noOfPhotocopy * 0.10;
    JOptionPane.showMessageDialog(null, "Total price is RM" +totalprice);
    }
 }

我必须为我的编程课程做一个项目,我的项目是帮助人们计算不同类型复印件的复印总价。

有错误,我修正了它们。 喜欢

if (type==G){// to compare use type.equals("G")

 String customer = "s_name";// not String customer"s_name;

 float totalprice; // to double totaleprice

试试这个解决方案就可以了

import javax.swing.JOptionPane;

public class 项目 1 {

public static void main(String[] args) {

    int noOfPhotocopy;
    double totalprice;

    String customer = "s_name";
    customer = JOptionPane.showInputDialog("Enter customer's name: ");

    String type = JOptionPane.showInputDialog("Choose type of photocopy: G/C").toUpperCase();

    if (type.equals("G")) {
        noOfPhotocopy = Integer.parseInt(JOptionPane
                .showInputDialog("Enter no of photocopy: "));

        if (noOfPhotocopy < 10) {
            totalprice = noOfPhotocopy * 0.10;
            JOptionPane.showMessageDialog(null, "Total price is RM"
                    + totalprice);
        } else if (noOfPhotocopy >= 10) {
            totalprice = noOfPhotocopy * 0.05;
            JOptionPane.showMessageDialog(null, "Total price is RM"
                    + totalprice);
        }
    }
        else if (type.equals("C")) {
            noOfPhotocopy = Integer.parseInt(JOptionPane
                    .showInputDialog("Enter no of photocopy: "));

            if (noOfPhotocopy < 10) {
                totalprice = noOfPhotocopy * 0.20;
                JOptionPane.showMessageDialog(null, "Total price is RM"
                        + totalprice);
            } else if (noOfPhotocopy >= 10) {
                totalprice = noOfPhotocopy * 0.10;
                JOptionPane.showMessageDialog(null, "Total price is RM"
                        + totalprice);
            }
        }       
    }
}