منتدى مصر التقني
هل تريد التفاعل مع هذه المساهمة؟ كل ما عليك هو إنشاء حساب جديد ببضع خطوات أو تسجيل الدخول للمتابعة.

أكتب برنامج لغة الجافا لحساب قيمة المراد دفعها للحصول على المنتجات التالية

اذهب الى الأسفل

أكتب برنامج لغة الجافا لحساب قيمة المراد دفعها للحصول على المنتجات التالية Empty أكتب برنامج لغة الجافا لحساب قيمة المراد دفعها للحصول على المنتجات التالية

مُساهمة من طرف منوشا,, الثلاثاء ديسمبر 11, 2012 2:54 pm

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

عندي برنامجين ف الجافا مو عارفة احلها

الي يعرف يفيدني وضرووووووووووري ابغى الحل اليوم





السؤال الاول:



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 Sad 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 Sad in this program you can use any type of loop and one class).



السؤال الثاني اريد الحل بطريقة: JOptionPane



وشكرا
منوشا,,
منوشا,,
.
.

تاريخ التسجيل : 11/12/2012
المساهمات : 2
النقاط : 4
التقيم : 0
الدولة : السعودية
الجنس : انثى

الرجوع الى أعلى الصفحة اذهب الى الأسفل

أكتب برنامج لغة الجافا لحساب قيمة المراد دفعها للحصول على المنتجات التالية Empty رد: أكتب برنامج لغة الجافا لحساب قيمة المراد دفعها للحصول على المنتجات التالية

مُساهمة من طرف أحمد مناع الثلاثاء ديسمبر 11, 2012 7:06 pm

بداية أهلا وسهلا أختى الكريمة و مرحبا بك فى منتدى مصر التقنى ......بالنسة للسؤال الاول





الحل على النحو التالى :



الكود:

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 );
    }
}

 




و اتمنى ان تكون الاكواد سهلة للفهم ....

ـــــــــــــــــــ التوقيع ــــــــــــــــــــ
سبحان الله وبحمدة .....سبحان الله العظيم
أحمد مناع
أحمد مناع
.
.

تاريخ التسجيل : 15/02/2011
المساهمات : 1108
النقاط : 202034
التقيم : 144
الدولة : مصر
الجنس : ذكر

https://egy-tech.forumegypt.net

الرجوع الى أعلى الصفحة اذهب الى الأسفل

أكتب برنامج لغة الجافا لحساب قيمة المراد دفعها للحصول على المنتجات التالية Empty رد: أكتب برنامج لغة الجافا لحساب قيمة المراد دفعها للحصول على المنتجات التالية

مُساهمة من طرف منوشا,, الأربعاء ديسمبر 12, 2012 2:55 pm

يعطيك الف عافية السؤال الاول تماام

بس السؤال الثاني لازم استخدم اي نوع من انواع اللوب
منوشا,,
منوشا,,
.
.

تاريخ التسجيل : 11/12/2012
المساهمات : 2
النقاط : 4
التقيم : 0
الدولة : السعودية
الجنس : انثى

الرجوع الى أعلى الصفحة اذهب الى الأسفل

الرجوع الى أعلى الصفحة

ََ

مواضيع ذات صلة


 
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى