دورات هندسية

 

 

Java java(((الى خبراء الجافا دخلوا هنا بليز)))java java

النتائج 1 إلى 3 من 3
  1. [1]
    Manal2009
    Manal2009 غير متواجد حالياً

    جديد

    تاريخ التسجيل: May 2009
    المشاركات: 2
    Thumbs Up
    Received: 0
    Given: 0

    Java java(((الى خبراء الجافا دخلوا هنا بليز)))java java

    السلام عليكم ...
    انا عضوة جديدة ومبتدئة الجافا وعندي سؤالين حاولت احلهم بس ما طلع صح بليز صلحولي الكودات

    Question 1 : Write a Java application which meets the following requirements: 1. In the application, you should declare a class called “Vehicle” with the following details:

    VN Vehicle Number
    VName Vehicle Name
    VCol Vehicle Colour
    VPrice Vehicle Price
    VTax Vehicle Tax
    VTPrice Vehicle Total Price Member Function

    getValues() Should read values for the member variables VNo, VNname, VCol, VPrice, VTax .

    CalculatePrice() Should calculate the VTPrice as the sum of the VPrice and VTax. PrintValues() Should print the value of the instance variables.

    2. In your main method, create N number of Vehicle objects, where the value of N is obtained from the user and store the objects into an array.

    3. Use appropriate methods to read the values of the Vehicle objects from user, calculate the price for each vehicle and print vehicle details and price details of all objects created.

    4. Use exception handling appropriately.

    5. Use comments to illustrate the various concepts applied / utilized in the solution.

    6. Ensure the use of meaningful variable names, consistent indentation of program code

    هذا الكود :
    This is my solution :
    import java.io.*;
    class Vehicle
    {
    int VehicleNo;
    String VehicleName;
    String VehicleColour;
    int VehiclePrice;
    int VehicleTax;
    int VehicleTotalPrice;

    {
    public void getValue()
    try
    {
    DataInputStream in=new DataInputStream(System.in);
    VNo=Integer.parselnt(VehicleNo.readLine());
    System.out.println("Enter Vehicle Number:");
    System.out.println("Enter Vehcile Name:");
    System.out.println("Enter Vehcile Colour:");
    VP=Integer.parselnt(VehiclePrice.readLine());
    System.out.println("Enter Vehicle Price:");
    VT=Integer.parselnt(VehicleTax.readLine());
    System.out.println("Enter Vehicle Tax:");
    }
    catch(Eception e){}


    public void CalculatePrice()
    {
    int VTPrice;
    VTPrice=VPrice+VTax;
    System.out.println("The Total Price is"+VTPrice);
    }
    public PrintValues()
    {
    System.out.println("Vehicle Number="+VehicleNo);
    System.out.println("Vehicle Name="+VehicleName);
    System.out.println("Vehicle Colour="+VehicleColour);
    System.out.println("Vehicle Price="+VehiclePrice);
    System.out.println("Vehicle Tax="+VehicleTax);
    }
    }

    class Qestion1
    {
    public static void main(String args[])
    {
    Vehicle V=new Vehicle();
    V.getValues(1234,BMW,Black,25000,100);
    V.printValues();
    V.CalculatePrice;
    }
    }
    }




    Question 2: 5 Marks Create a JAVA applet program that converts US Dollars to Riyal Omani. The Applet consists of five GUI components as two labels USD and RO followed by two textfields of size 10 respectively and a button labelled as CONVERT. The USD value should be entered from the keyboard on the first textfield component. Pressing the button should cause the number of US dollars entered to be converted into Riyal Omani and displayed on the second textfield. Use the following hint for the conversion.

    والسؤال الثاني ماعرفت الكود

    بليييييييييييييييييييييييز لا اطنشوني لأني محتاجة الكودات في اسرع وقت...

  2. [2]
    Broker99
    Broker99 غير متواجد حالياً
    جديد


    تاريخ التسجيل: May 2009
    المشاركات: 3
    Thumbs Up
    Received: 0
    Given: 0
    The first file is as follow:

    import java.util.*;


    public class Vehicle

    {
    private int VNo;
    private String VName;
    private String VColour;
    private int VPrice;
    private int VTax;
    private int VTotalPrice;

    public void getValue()
    {


    Scanner in = new Scanner(System.in);
    System.out.println("Enter Vehicle Number: ");
    VNo = in.nextInt();
    VName= in.nextLine(); // skip the new line charechter
    System.out.println("Enter Vehcile Name: ");
    VName= in.nextLine();
    System.out.println("Enter Vehcile Colour: ");
    VColour = in.nextLine();
    System.out.println("Enter Vehicle Price: ");
    VPrice = in.nextInt();
    System.out.println("Enter Vehicle Tax: ");
    VTax = in.nextInt();

    }// getValue()
    //================================
    public void CalculatePrice()
    {
    int VTPrice;
    VTotalPrice = VPrice + VTax;
    }// Calc
    //==========================
    public void PrintValues()

    { System.out.println("-----------------------");
    System.out.println("Vehicle Number = "+VNo);
    System.out.println("Vehicle Name = "+VName);
    System.out.println("Vehicle Colour = "+VColour);
    System.out.println("Vehicle Price = "+VPrice);
    System.out.println("Vehicle Tax = "+VTax);
    System.out.println("Total price is = "+ VTotalPrice);
    System.out.println("\n-----------------------");
    }// print

    //=============================


    }//END of class Vehicle

    and the second file is

    import java.util.*;

    public class Main {

    public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    // maximum number of cars to be processed
    final int MAX_CARS = 10;
    // this array will save an objects of vehicles
    Vehicle[] vehicles = new Vehicle[MAX_CARS];
    // this is the user input represents the number of wanted car
    int numberOfCars=-1;
    do
    {
    try{
    //first read the number of cars from the user
    System.out.println("Enter number of cars (maximum "+MAX_CARS+" cars): ");
    numberOfCars = in.nextInt();
    if(numberOfCars > MAX_CARS || numberOfCars < 0)
    System.out.println("ERROR: enter a number between 1,"+MAX_CARS);
    }// try

    catch(InputMismatchException e){
    in.nextLine();
    System.out.println("ERROR: input was not numeric");
    }// catch
    }while ( !(numberOfCars >= 0 && numberOfCars <= MAX_CARS));




    // then process cars
    for(int i=0;i<numberOfCars;i++)

    {
    try
    {
    System.out.println("VEHICLE# "+(i+1));
    vehicles[i] = new Vehicle();
    vehicles[i].getValue();
    }
    catch(InputMismatchException e){
    in.nextLine();
    //then re enter the failed item again
    i--;
    System.out.println("Invalid input, input was not numeric");}
    }
    // then print them out
    for (int i=0;i<numberOfCars;i++)
    { // calculate the price
    vehicles[i].CalculatePrice();
    System.out.println("\nCAR NUMBER "+(i+1));
    // then print it
    vehicles[i].PrintValues();
    }
    }

    }

    i have test this program and is working correctly, and will handle the input perfectly

    enjoy this code

    best wishes

    0 Not allowed!



  3. [3]
    Manal2009
    Manal2009 غير متواجد حالياً
    جديد


    تاريخ التسجيل: May 2009
    المشاركات: 2
    Thumbs Up
    Received: 0
    Given: 0
    Thanx alot for helping me ..
    i will try it ..
    :)

    0 Not allowed!



  
الكلمات الدلالية لهذا الموضوع

عرض سحابة الكلمة الدلالية

RSS RSS 2.0 XML MAP HTML