أكتب برنامج لغة الجافا لحساب قيمة المراد دفعها للحصول على المنتجات التالية
منتدى مصر التقني :: قسم لغات البرمجة Programming languages :: لغة الجافا Java :: نقاش و أستفسارات الاعضاء
صفحة 1 من اصل 1 • شاطر
أكتب برنامج لغة الجافا لحساب قيمة المراد دفعها للحصول على المنتجات التالية
السلام عليكم ةرحمة الله وبركاته
عندي برنامجين ف الجافا مو عارفة احلها
الي يعرف يفيدني وضرووووووووووري ابغى الحل اليوم
السؤال الاول:
A cloth showroom has announced the following seasonal discounts on purchase of items.
Write java program in two classes, use switch and if -statement to compute the net amount to be paid by a customer.
Note that in this program we can use toCharArray()[0]
When you enter the value of type_item
Convert string to char array).
السؤال الثاني:
The total distance travelled by a vehicle in t seconds is given by: Distance= ut + (at2 ) / 2
Where u is the initial velocity (meters per second),
a is the acceleration (meters per second2 ).
Write java program in one class to evaluate the distance travelled at regular intervals of time, given the value of u and a. The program should provide the flexibility to the user to select his own time intervals and repeat the calculations for different value of u and a.
Note that in this program you can use any type of loop and one class).
السؤال الثاني اريد الحل بطريقة: JOptionPane
وشكرا
عندي برنامجين ف الجافا مو عارفة احلها
الي يعرف يفيدني وضرووووووووووري ابغى الحل اليوم
السؤال الاول:
A cloth showroom has announced the following seasonal discounts on purchase of items.
Purchase amount | Discount | |
Mill – cloth item | Handloom item | |
0 - 100 | ------- | 5.0% |
101 - 200 | 5.0% | 7.5% |
201 - 300 | 7.5% | 10.0% |
Above 300 | 10.0% | 15.0% |
Write java program in two classes, use switch and if -statement to compute the net amount to be paid by a customer.
Note that in this program we can use toCharArray()[0]
When you enter the value of type_item
Convert string to char array).
السؤال الثاني:
The total distance travelled by a vehicle in t seconds is given by: Distance= ut + (at2 ) / 2
Where u is the initial velocity (meters per second),
a is the acceleration (meters per second2 ).
Write java program in one class to evaluate the distance travelled at regular intervals of time, given the value of u and a. The program should provide the flexibility to the user to select his own time intervals and repeat the calculations for different value of u and a.
Note that in this program you can use any type of loop and one class).
السؤال الثاني اريد الحل بطريقة: JOptionPane
وشكرا
منوشا,,- .
- تاريخ التسجيل : 11/12/2012
المساهمات : 2
النقاط : 4
التقيم : 0
الدولة :
الجنس :
رد: أكتب برنامج لغة الجافا لحساب قيمة المراد دفعها للحصول على المنتجات التالية
بداية أهلا وسهلا أختى الكريمة و مرحبا بك فى منتدى مصر التقنى ......بالنسة للسؤال الاول
الحل على النحو التالى :
مع ملاحظة أن حرف H يرمز للصنف Handloom item و الحرف M ببصنف Mill – cloth item
و اتمنى ان تكون الاكواد سهلة للفهم ....
الحل على النحو التالى :
- الكود:
package test;
import java.util.Scanner;
class info {
char type;
int quantity;
double price;
Scanner input = new Scanner(System.in);
public info(){
}
public char type(){
System.out.print("Enter the type M or H!");
String name =input.nextLine();
type=name.charAt(0);
return type;
}
public int quantity(){
System.out.print("Enter the quantity!");
quantity =input.nextInt();
return quantity;
}
public double price(){
System.out.print("Enter the price!");
price=input.nextDouble();
return price;
}
}
public class Test {
public static void main(String[] args) {
double discount;
double total;
info b1= new info();
b1.type();
b1.quantity();
b1.price();
switch(b1.type){
case 'M':
if(b1.quantity<=100){
discount=0;
total=(b1.quantity*b1.price);
System.out.print("Net value that customers must pay are: " + total);
}
else if(b1.quantity==200 ||b1.quantity<=101 ){
discount=(b1.quantity*b1.price)*.05;
total=(b1.quantity*b1.price)-discount;
System.out.print("Net value that customers must pay are: " + total);
}
else if(b1.quantity>=300){
discount=(b1.quantity*b1.price)*.10;
total=(b1.quantity*b1.price)-discount;
System.out.print("Net value that customers must pay are: " + total);
}
break;
case 'H':
if(b1.quantity<=100){
discount=(b1.quantity*b1.price)*.05;
total=(b1.quantity*b1.price)-discount;
System.out.print("Net value that customers must pay are: " + total);
}
else if(b1.quantity<=200 ||b1.quantity<=101){
discount=(b1.quantity*b1.price)*.075;
total=(b1.quantity*b1.price)-discount;
System.out.print("Net value that customers must pay are: " + total);
}
else if(b1.quantity>=300){
discount=(b1.quantity*b1.price)*.15;
total=(b1.quantity*b1.price)-discount;
System.out.print("Net value that customers must pay are: " + total);
}
break;
default:
System.out.print("Sorry, but this type is not known to the program");
}
b1.input.close();
}
}
مع ملاحظة أن حرف H يرمز للصنف Handloom item و الحرف M ببصنف Mill – cloth item
بالنسبة للسؤال الثانى .... الحل سيكون على النحو التالى
- الكود:
package test;
import javax.swing.JOptionPane;
public class Test {
public static void main(String[] args) {
String no1,no2;
float a,u,Distance;
final int T=2;
no1=JOptionPane.showInputDialog(null,"Enter velocity !","dialog",2);
no2=JOptionPane.showInputDialog(null,"Enter acceleration !","dialog",2);
a=Float.parseFloat(no2);
u=Float.parseFloat(no1);
Distance=(u * T) + (a * T * 2)/T;
JOptionPane.showMessageDialog(null, "Distance is "+ Distance , "dialog", 2);
System.exit( 0 );
}
}
و اتمنى ان تكون الاكواد سهلة للفهم ....
ـــــــــــــــــــ التوقيع ــــــــــــــــــــ
سبحان الله وبحمدة .....سبحان الله العظيم
رد: أكتب برنامج لغة الجافا لحساب قيمة المراد دفعها للحصول على المنتجات التالية
يعطيك الف عافية السؤال الاول تماام
بس السؤال الثاني لازم استخدم اي نوع من انواع اللوب
بس السؤال الثاني لازم استخدم اي نوع من انواع اللوب
منوشا,,- .
- تاريخ التسجيل : 11/12/2012
المساهمات : 2
النقاط : 4
التقيم : 0
الدولة :
الجنس :
| |
منتدى مصر التقني :: قسم لغات البرمجة Programming languages :: لغة الجافا Java :: نقاش و أستفسارات الاعضاء
صفحة 1 من اصل 1
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى
أمس في 8:56 pm من طرف moslema_r
» شركة مكافحة حشرات في راس الخيمة
أمس في 8:34 pm من طرف moslema_r
» تطبيقIncogniton لإدارة ملفات تعريف متعددة للمتصفح
الأربعاء أبريل 24, 2024 3:51 pm من طرف زاكااا
» افضل شركة مكافحة النمل الابيض بالرياض
الإثنين أبريل 22, 2024 9:41 pm من طرف moslema_r
» Exemplary Сasual Dating - Verified Women
الخميس أبريل 18, 2024 9:18 pm من طرف wdqwd
» رش الدفان بالرياض
الخميس أبريل 18, 2024 7:11 pm من طرف moslema_r
» شركة تنظيف خزانات الشارقة
الخميس أبريل 18, 2024 6:57 pm من طرف moslema_r
» شركة مكافحة الفئران بالرياض
الإثنين أبريل 15, 2024 8:23 pm من طرف moslema_r
» افضل شركة كشف تسربات المياه بالباحة
الخميس أبريل 04, 2024 7:02 am من طرف gmalnagy
» ساعدوني وفهموني help me
الجمعة مارس 29, 2024 8:37 am من طرف linesoft