السلام عليكم
مسائكم / صباحكم سكر
طلب منا مشروع بسيط نستخدم فيه ال ARRAAY وانا عملت مشروع عباره عن آلة قهوه Coffe Machine والمشروع ماشي معاي تمام بس انا ابيه يحسب الباقي من السعر بمعنى اذا ادخل المستخدم عملة من فئة 5 وسعر الكوب 2 يرجع لي الباقي اللي هو عملة من فئة 3
بس ما عرفت الكود اتوقع نستخدم فيه %
ياليت تساعدوني مشكوورييين (^_^)
وهذا كود المشروع
import javax.swing.*;
class Coffee{
public static void main(String[] args){
JOptionPane.showMessageDialog(null,".............Welcome In My Coffee.............");
int type, num;
double price=2.0;
String [] Coffee={"Coffee","Coffee","Coffee","Coffee","Coffee"};
String [] Capput={"Capput","Capput","Capput","Capput","Capput"};
type=Integer.parseInt(JOptionPane.showInputDialog(null," Enter your choice \n"+
"1* Coffee \n"+"2* Capputccino"));
while(type <1 || type >2){
JOptionPane.showMessageDialog(null,"Yore choice an invalid \n "+"Choose agine");
type=Integer.parseInt(JOptionPane.showInputDialog(null," Enter your choice \n"+
"1* Coffee \n"+"2* Capputccino"));
}
if (type==1)
for (int i=0 ;i<Coffee.length ;i++){
num=JOptionPane.showConfirmDialog(null,"You will take "+(1+i)+"Cup of Coffee \n Do you want more Cup?","",JOptionPane.YES_NO_OPTION);
if(num==JOptionPane.NO_OPTION){
JOptionPane.showMessageDialog(null,"Take Your Cup \n"+"The Price is "+price*(i+1));
break;
}
if (i==4)
JOptionPane.showMessageDialog(null,"Sorry There Are 5 Cups Only \n Take It ... \n And If You need more Cups Try After 5 Hours (^_^)");
}
else if (type==2)
for (int i=0 ;i<Capput.length ;i++){
num=JOptionPane.showConfirmDialog(null,"You will take "+(1+i)+"Cup of Cappuccino \n Do you want more Cup?","",JOptionPane.YES_NO_OPTION);
if(num==JOptionPane.NO_OPTION){
JOptionPane.showMessageDialog(null,"Take Your Cup \n"+"The Price is "+price*(i+1));
break;
}
if (i==4)
JOptionPane.showMessageDialog(null,"Sorry There Are 5 Cups Only \n Take It ... \n And If You need more Cups Try After 5 Hours (^_^)");
}
JOptionPane.showMessageDialog(null,".*..*.Thank you to use this Machine.*..*. \n ..*..Come Agin (^_^)..*..");
}
}