الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

تصحيح كود و إتمامه

بدأه soooma في 14 ديسمبر 2010 · 1 رد · 424 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

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

عندي سؤال أعطتني هو الأستاذة ومطالبة بتسليمو غداً الساعة الواحدة ظهراً كحد أعلى أتمنى أن تساعدوني فيه

السؤال:

Write a java program which checks whether a patient’s blood pressure is normal or not and report it accordingly.

You are required to define two classes.

Blood_Pressure

Patient

The Blood_Pressure should contain the following data members

Upper //for upper value of the blood pressure

Lower //for lower value of the blood pressure

The Patient class should contain the following data members

Name //for name of the patient

BP //for patient’s blood pressure, should be of type Blood_Pressure

Write an input function for the class Patient that takes input for Name and BP. For BP, it should take input of Lower and Upper.

Class Patient should also contain a member function that checks and reports whether the blood pressure is normal or not.

Blood pressure is considered as normal if the upper value is equal to 120 and lower is equal to 80. For all other values of upper and lower, the blood pressure is considered as not normal.

If it founds a normal blood pressure it displays a message

“Blood pressure is normal”

On the other hand on finding out a blood pressure which is not normal it displays a message that says

“Blood pressure is not normal”

Write setter and getter functions for the data members; lower, upper and name in their respective classes. Also write constructor.

وهذا هو الكود الذي كتبته:

import java.util.Scanner;

class Ass

{

public static int Blood_Pressure;

public static int Patient;

private int upper;

private int lower;

private String name;

public void setupper( int u)

{

upper = u;

}

public int getupper()

{

return upper;

}

public void setlower( int l)

{

lower = l;

}

public int getlower()

{

return lower;

}

public void setname(String n)

{

name = n;

}

public String getname()

{

return name;

}

Ass()

{

if (upper == 120){

System.out.println("Normal");}

else{

System.out.println("Not Normal");}

}

Ass(int x)

{if (lower == 80){

System.out.println("Normal");}

else{

System.out.println("Not Normal");}

}

public String toString()

{

return ("Name" +name+ "\nupper" +upper+ "\nlower" +lower);

}

public static void main(String [] args)

{

Scanner input = new Scanner(System.in);

Ass a1 = new Ass();

int x = input.nextInt();

a1.setupper (x);

int y = input.nextInt();

a1.setlower (y);

String z = input.next();

a1.setname (z);

Ass a2=new Ass();

a2.toString();

}

}

وجزاكم الله خيراً مقدماً

#2

ممكن تحددين وين الغلط بالضبط علشان نساعدك فيه ..

You CAN

مواضيع مشابهة