الانتقال إلى المحتوى
View in the app

A better way to browse. Learn more.

مجموعة مستخدمي أوراكل العربية

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

محتاج مساعدة في حل مسائل جافا عاجل

Featured Replies

بتاريخ:

السلام علبكم ريد مساعد في حل مسئلتين صعبني شوي بليز ...

 

1. Write Java code for the following scenario:

a. Create class to represent a Student details StudentID, StudentName, ModuleName, and StudentMarks. Choose appropriate data type for each attribute.

b. Implement a constructor to initialize all the member variables from given parameters.

c. Methods:  void Display() to display the all the details of the Student.

 void UpdateMarks(double MK) to update StudentMarks of the student.

d. Write a custom exception for the following situations while updating marks

 When Student marks are updated with a value less than or equal to zero a custom exception must be raised with the following message “Student Marks cannot be zero/ less than zero”.

 When Student marks are updated with a value greater than hundred a custom exception must be raised with the following message “Student Marks cannot be greater than hundred”.

e. invoke both custom exceptions in UpdateMarks methodf. Implement a class MainClass hosting Main

 

 Create object of Student class. Call all the methods in such a way that all custom exceptions are raised.

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

 

 

2. Write Java code for the following scenario: a. Create class to represent a LibraryMember details MemberID, MemberName, Department, and TotalBooks.

Choose appropriate data type for each attribute.

b. Implement a constructor to initialize all the member variables from given parameters.

c. Methods:  void Display() to display the all the details of the Student.

d. Write a custom exception for the following situations while issue and returning of books

 When Member is issued books TotalBooks attribute is updated by adding number of books issued to TotalBooks. After addition if TotalBooks is 6 or more a custom exception must be raised with the following message “Member cannot be issued more than five books”.

 When Member is returns a book TotalBooks attribute is updated by subtracting the number of books from the TotalBooks. If after subtracting TotalBooks reduces to Zero a custom exception must be raised with the following message “Member has returned all the books”.

e. Assume the following methods for the above exceptions.

 void issue(int NoofBooks).

 void Return(int NoofBooks).

f. Implement a class MainClass hosting Main(): 

 Create object of Student class. Call all the methods in such a way that all custom exceptions are raised.

بتاريخ:

هذا الكود يحقق ما سألت عنه في السؤال الأول بكل فروعه ووضعت تعليق توضيحي في بداية كل method

import javax.swing.JOptionPane;

public class Student extends Exception
{
   /* a. Create class to represent a Student details StudentID, 
    * StudentName, ModuleName, and StudentMarks 
    * Choose appropriate data type for each attribute.*/ 
    int studentID;
    String studentName;
    Double studentMarks;
    String moduleName;
      
 /* b. Implement a constructor to initialize all the member variables from given parameters.*/
  public Student(int studentID,String studentName,Double studentMarks,String moduleName) 
    {
        this.studentID=studentID;
        this.studentName=studentName;
        this.studentMarks=studentMarks;
        this.moduleName=moduleName;
   }

  /* c. Methods: void Display() to display the all the details of the Student*/  
    public void displayDetails()
    {
     System.out.println("The Student Id is " + studentID);
     System.out.println("The Student Name is " + studentName);
     System.out.println("The Student markrs is " + studentMarks);
     System.out.println("The Student Module is " + moduleName);
   } 
    private Student() { }
    public Student(String message) 
    {
      super(message);
    } 
   /* void UpdateMarks(double MK) to update StudentMarks of the student.
    d. Write a custom exception for the following situations while updating marks
     When Student marks are updated with a value less than or equal to zero 
    a custom exception must be raised with
     the following message “Student Marks cannot be zero/ less than zero”.
     When Student marks are updated with a value greater than hundred a 
    custom exception must be raised with 
     the following message “Student Marks cannot be greater than hundred”.*/  
  
  
   public void updateMarks(double MK)  
   {
      Student student = new Student();
      student.exceptionLessupdateMarks(MK);
      student.exceptionGreatUpdateMarks(MK);
   }
  /*Custom Exception For Mark Less Than Zero*/
  public void exceptionLessupdateMarks(double MK)   
    {   
         try
         {
             if(MK<=0)
             {
                  throw new Student();
             }
         }
         catch(Student ex)
         {
              System.out.println("Student Marks cannot be zero/ less than zero");
         }
     }
  
    /*Custom Exception For Mark Greater Than hundred*/
    public void exceptionGreatUpdateMarks(double MK)   
      {   
           try
           {
               if(MK>100)
               {
                    throw new Student();
               }
           }
           catch(Student ex)
           {
                System.out.println("Student Marks cannot be greater than hundred");
           }
       }
    
  /*
  e. invoke both custom exceptions in UpdateMarks methodf. Implement a class MainClass hosting Main
     Create object of Student class. Call all the methods in such a way that all custom exceptions are raised.
 */
    public static void main(String[] args) 
   {
     String studentID = JOptionPane.showInputDialog("Please Enter Student ID");
     String studentName = JOptionPane.showInputDialog("Please Enter Student Name ");
     String studentMarks = JOptionPane.showInputDialog("Please Enter Student Marks ");
     String moduleName = JOptionPane.showInputDialog("Please Enter Student Module");
     Student student = new Student(Integer.parseInt(studentID),studentName,Double.parseDouble(studentMarks),moduleName);
     student.displayDetails();
     String studentMarksUpdate = JOptionPane.showInputDialog("Updat Student Mark");
     student.updateMarks(Double.parseDouble(studentMarksUpdate));
    }
           
}

السؤال الثاني حاول أن تستفد من حل السؤال الأول وقم بحله فهو مشابه تقريباً

وبالتوفيق 

بتاريخ:
  • كاتب الموضوع

شكرا جزيلا اختي العزيزه على مجهودك وفقك الله

بتاريخ:

العفو..بالتوفيق إن شاء الله

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية

Account

Navigation

البحث

إعداد إشعارات المتصفح الفورية

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.