بســم الله الـرحمــن الرحيــم
السلام عليكــم ورحمـة الله وبركاتــه ،،
في عندي مشكلة عقدتني في الجافا ابغى المثود اللي اسمها setcustomGenger اذا المستخدم دخل male او femaleسوا بكبتل او سمول يقبل واذا غيرها يرفض ويخرجه من البرنامج
وعندي مشكلة ثانية في المثود اللي اسمها read اذا اختار المستخدم رقم 1 ابغاه يطلع اسم السيارة و السعرالموجود في الmain(الأسعار اللي انا حاطتها افتراضية)
الله يسعدكم ضروري ابغى الحل اليوم .........
وهاذي الmain.......
/**
* @(#)buy_cars.java
*
* buy_cars application
*
* @author
* @version 1.00 2009/5/23
*/
import java.util.*;
import java.text.*;
public class buy_cars {
public static void main(String[] args) {
// .......The menu of store..........
System.out.println(" ****************************** ");
System.out.println(" *** ** Welome In Stors of Cars ** ***" );
System.out.println(" ****************************** ");
System.out.println("no type of cars price of cash " );
System.out.println(" 1 Jeep 150,000 ");
System.out.println(" 2 Cammri 90,000 ");
System.out.println(" 3 Corella 75,000 ");
System.out.println(" 4 Macrobus 80,000 ");
System.out.println(" 5 Oruin 130,000 ");
// .........deacleartion and creation of object .........
Customers C=new Customers();
CarsInfo obj=new CarsInfo ();
System.out.println("\n_______________\n 1- Read customers\n 2-Read cars Informatin \n 3- User Report\n ________________");
Scanner sn=new Scanner(System.in);
int ch=sn.nextInt();
switch(ch){
case 1:{C.setcustName();C.setcustAge();C.setcustGender();C.setcustjob();C.setcustId()
;
System.out.println("_______Thank you For any Qustion pleaze call to:0533018947________");}break;
case 2: obj.read();
break;
case 3:{ }break;
default:System.out.println("Sorry wrong choise tray again latter");
}
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.وهاذي الكلاسات
import java.util.*;
class CarsInfo {
static int count=1;
int carprice;
String carname;
double salary;
Scanner scan =new Scanner(System.in);
public CarsInfo()
{
carprice=0;
carname=null;
count++;
}
public String getcarname ()
{
return carname ;
}
public int getcarprice()
{
return carprice;
}
public String toString()
{
return "\n name of car:"+getcarname ()+"\t the car price is:"+getcarprice();
}
public void setcarprice()
{
System.out.println("Which kind of car would you to pay? \n chose any from the menu...");
int x ;
x=scan.nextInt();
if (x==1)
System.out.println ("150,000");
}
public void read ( ){
System.out.println( "would the customer want to buy the car cash or installment by months");
System.out.println("=====================================================================");
System.out.println( "Which kind of car would you to pay?");
String car=scan.next();
System.out.println("How much the customer salary?" );
double salary =scan.nextDouble();
System.out.println("Enter [1]For Cash \n");
System.out.println(" [2] For installment" );
int chose=scan.nextInt();
if (chose==1)
System.out.println("The car price is "+getcarprice());
else if (chose==2)
{ if (salary>=4000)
{System.out.println("The installment opertion accepted" );
double opertion=(salary*15)/100;
System.out.println("The installment in one month is"+ opertion);
double totalyear; totalyear=opertion*12;
do{
totalyear+=totalyear;
totalyear++;
}while (totalyear==carprice);
System.out.println(" The totalyear ="+totalyear);
}
}
}
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
/**
* @(#)Customers.java
*
*
* @author
* @version 1.00 2009/5/23
*/
import java.util.*;
import java.text.*;
public class Customers {
// data members
public int customerId;
public String customerName;
public String customerGender;
public int customerAge;
public String customerJop;
Scanner scan=new Scanner(System.in);
// constructure
public Customers(){
customerId=0;
customerName="null";
customerGender="null";
customerAge=20;
customerJop="null";
}
// method
public int getcustId(){
return customerId;
}
public void setcustId(){
System.out.print("\n5-Enter the number of credit card:");
customerId=scan.nextInt();
}
public void setcustName(){
System.out.print("\n1-Enter the account holder Name: ");
customerName=scan.next();
}
public String getcustName(){
return customerName;
}
public void setcustGender(){
System.out.print("\n3-Enter your gender(Female or Male): ");
customerGender=scan.next();
if(customerGender=="Male" || customerGender=="male")
getcustGender();
else
if(customerGender=="Female" || customerGender=="female")
getcustGender();
}
public String getcustGender(){
return customerGender;
}
public void setcustjob( ){
System.out.print("\n4-Enter your jop please: ");
customerJop=scan.next();
}
public String getcustjob(){
return customerJop;
}
public void setcustAge( ){
System.out.print("\n2-Enter your age please: ");
customerAge=scan.nextInt();
if(customerAge<18 || customerAge>45)break;
}
public int getcustAge(){
return customerAge;
}
public String toString(){
return getcustId()+" \n "+getcustId()+ "\n "+getcustName()+"\n "+ getcustGender()+"\n"+getcustjob()+"\n "+getcustAge();
}
}
