الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

ايش المشكله

مغلقمُجاب
بدأه R-rema في 24 أكتوبر 2013 · 3 رد · 723 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع
package customer;

import java.util.Scanner;

public class Customer {

   
    public static void main(String[] args) {
String customerr;
int name;
int adress;
int phoneNumber;
Scanner input=new Scanner(System.in);
System.out.println("please enter your name");
customerr=input.nextLine();
name=input.nextInt();
adress=input.nextInt();
phoneNumber=input.nextInt();

switch(customerr){
    case "Ahmad":
    case "0555150055":
    
      System.out.println("Hello Ahmad ,you will get a 10% discount from the total payment");
      System.out.println("total priceis: 3700 SR ,you will be directed to our E-payment page" );
      System.out.println("thank you for using our System " );
break;
    case "Mohammad Abdullah":
    case "0595911919":
   
      System.out.println("Hello Mohammad Abdullah,you will get a 10% discount from the total payment");
      System.out.println("total priceis: 3600 SR ,you will be directed to our E-payment page" );
      System.out.println("thank you for using our System " );
break;
default:
    System.out.println("Hello " +name+ "please complete you information");
    System.out.println("you phone number :"+adress );
    System.out.println("you phone number :"+phoneNumber );
    System.out.println("total priceis: 3500 SR ,you will be directed to our E-payment page" );
    System.out.println("thank you for using our System " );



}
    }
}

السلام عليكم ورحمة الله وبركاته

عندي برنامج بـ swich

مايطلع لي error  ومو راضي يتنفذ

ممكن تقولين لي ايش المشكله

#2 أفضل إجابة

استخدم الميثودز وانشئ صف خاص بالـcustomer كما يلي :

package customer;

import java.util.Scanner;

public class Customer {

    String name;
    String adress;
    String phoneNumber;

    public String getAdress() {
        return adress;
    }

    public void setAdress(String adress) {
        this.adress = adress;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public void printAhmad() {
        System.out.println("Hello Ahmad ,you will get a 10% discount from the total payment");
        System.out.println("total priceis: 3700 SR ,you will be directed to our E-payment page");
        System.out.println("thank you for using our System ");
    }

    public void PrintCustomerdata() {
        System.out.println("Hello " + getName() + "please complete you information");
        System.out.println("you phone number :" + getAdress());
        System.out.println("you phone number :" + getPhoneNumber());
        System.out.println("total priceis: 3500 SR ,you will be directed to our E-payment page");
        System.out.println("thank you for using our System ");
    }

    public void setInfo() {
        Scanner input = new Scanner(System.in);
        System.out.println("please enter Customer name");
        setName(input.next());
        System.out.println("please enter Customer Address");
        setAdress(input.next());
        System.out.println("please enter Customer Phone");
        setPhoneNumber(input.next());
    }
}

يمكنك الان القيام بتفحص صفك class ضمن التشغيل كما يلي :

public class Run {

    public static void main(String[] args) {
        while (true) {
            Customer customer = new Customer();
            customer.setInfo();
            switch (customer.getName()) {
                case "Ahmad":
                    customer.printAhmad();
                    break;
                default:
                    customer.PrintCustomerdata();
                    break;
            }
        }
    }
}
1

||***************************************************||


 ||بسم الله الذي لا يعلو على اسمه شيء في الارض ولا في السماء وهو العلي العظيم ||


||***************************************************||


 ||                             اللهم إن لم يكن بك غضب علي فلا ابالي                       ||


||***************************************************||


في المنتديات العلمية استخدام التقييم rep_up.png  rep_down.png  يرفع من قيمة الموضوع واهمية الرد

#3

شكرا جزاكـ الله خيير

ضبط معاي

#4

تنبيه:

العنوان غير مناسب لمحتوى الموضوع, في المرات القادمة, اختاري عنوان يصف مشكلتك من الناحية التقنية و ليس مجرد "ايش كذا" :)

هذا الموضوع مغلق.

مواضيع مشابهة