البرمجة بالعراقي
Open in Telegram
هاي قناة سوينها ل طلاب علوم الحاسوب حتى نتعاون بيناتنا ونتعلم كل ما يتعلق بالبرمجة وايضا كلشي من ادوات ذكاء اصطناعي و مشاريع و بوتات رابط كروب مجموعة https://t.me/learn_javaaa
Show more833
Subscribers
No data24 hours
-57 days
-1330 days
Posts Archive
q2
package ms;
import java.util.Scanner;
class Animals{
Boolean vegetarian;
String eats;
int noOflegs;
public Animals(Boolean vegetarian,String eats, int noOflegs) {
this.vegetarian=vegetarian;
this.eats=eats;
this.noOflegs=noOflegs;
}
Boolean isVegetarian(){
return vegetarian;
}
void setVegetarian(Boolean vegetarian){
this.vegetarian=vegetarian;
}
String getEats(){
return eats;
}
void seEats(String eats){
this.eats=eats;
}
int getNoOflegs(){
return noOflegs;
}
void setNoOflegs(int noOflegs){
this.noOflegs=noOflegs;
}}
class Cat extends Animals{
String color;
public Cat(String color, Boolean vegetarian,String eats, int noOflegs) {
super(vegetarian, eats, noOflegs);
this.color=color;
}
String getColor(){
return color;
}
void setColor(String color){
this.color=color;
}
}
public class Ms {
public static void main(String[] args) {
Cat c=new Cat("black",false, "fish", 4);
System.out.println(" color: "+c.getColor()+"\n eats: "+c.getEats()+"\n is vegetarian? "+ c.isVegetarian()+"\n noOflegs= "+c.getNoOflegs());
}}
بدون اختصار هجي الحل
package ms;
import java.util.Scanner;
class Circle{
final static double pi=3.14;
double radius;
Circle(){
radius=1.0;
}
Circle(double radius)
{
this.radius=radius;
}
double getArea(){
return radius*radius*pi;
}
void display(){
System.out.println("radius is:"+radius+" \n Circle Area: "+getArea());
}
}
class Cylinder extends Circle {
double height;
Cylinder(){
height=1.0;
}
Cylinder(double radius,double height)
{
super(radius);
this.height=height;
super.radius=radius;
}
public double getVolume(){
//v = π*(r²)*h -> π=3.14
return 3.14*(super.radius*super.radius * height);
}
@Override
void display(){
System.out.println("height is:"+height+"\nCylinder Volume: "+getVolume());
}
}
public class Ms {
public static void main(String[] args) {
Circle s=new Circle();
s.display();
System.out.println("\n constructer 2: \n ");
Circle s1=new Circle(3);
s1.display();
System.out.println("\n valume of Cylinder");
Cylinder Cl=new Cylinder();
Cl.display();
System.out.println("\n constructer 2 \n");
Cylinder C2=new Cylinder(3.0,2.0);
C2.display();
}}
السؤال يطلب نعمل كونستركتر مرتين
مره قيمة ابتدائيه 1.0 وبدون متغيرات الكونستر فارغ من تستدعي الكلاس يستدعى وياه
ومرة الخ نخليها بالاستدعاء يعني من تستدعي الكلاس نخليها بين القوسين
طبعا الكود بي اختصار مخلي كلاس cylinder الاسطوانة هو يطبع مساحة الدائرة ومساحة الاسطوانة محاجه استدعي كلاس الدائرة حتى اطبع مساحة الدائرة
حل سؤال الاول
package ms;
import java.util.Arrays;
class Circle{
final static double pi=3.14;
double radius;
Circle(){
radius=1.0;
}
Circle(double radius)
{
this.radius=radius;
}
double getArea(){
return radius*radius*pi;
}
void display(){
System.out.println("radius is:"+radius+" \n Circle Area: "+getArea());
}
}
class Cylinder extends Circle {
double height;
Cylinder(){
height=1.0;
}
Cylinder(double radius,double height)
{
super(radius);
this.height=height;
}
public double getVolume(){
//π*r²*h
return getArea()*height;
}
@Override
void display(){
super.display();
System.out.println("height is:"+height+"\nCylinder Volume: "+getVolume());
}
}
public class Ms {
public static void main(String[] args) {
Cylinder Cl=new Cylinder();
Cl.display();
System.out.println("*****************");
Cylinder C2=new Cylinder(3.0,2.0);
C2.display();
}}
package tupac;
import java.util.Scanner;
import java.util.InputMismatchException;
public class Tupac {
public static void main(String[] args) {
Scanner mu=new Scanner(System.in);
try{
System.out.print("enter any num: ");
int n=mu.nextInt();
System.out.print(n);
}
catch(InputMismatchException ex){
System.out.print("datatype should be integer ");
}
}}
عرفت متغير من نوع انتجر بس اذا دخلت حرف اكيد يطلع خطأ
زين اكو طريقة ثانية اخلي مايطلع خطأ وبدون ما احولة string
بس يظهرلي رسالة تحذير
" المتغير يجب ان يكون من نوع انتجر "
من خلال مكتبة
import java.util.inputMismsrtException
ودالة try
حسين الربيعي الي كمل شهادة دكتوراه هندسة البرمجيات بجامعة نيويورك .
يتكلم عن الخطة الشاملة لتعلم البرمجة
https://youtu.be/L5OHgRTQHb4
الي عندهم امتحانات ويدرس ع كد الامتحان
ما عليكم بهذي الاسئلة اني احلها لنفسي وللناس الي تريد تطور نفسها
لأن اريد اوصل لحل 1500 سؤال قبل لا اوصل للبرمجة بشكل متقدم
Scanner mu = new Scanner(System.in);
int i,n;
System.out.print("Input num of students:");
n = mu.nextInt();
String a[]=new String[n]; // names of students
int b[][]=new int[n][2]; // degrees
for (i = 0; i < n; i += 1) {
System.out.print("Input name of student "+i+" :");
a[i] = mu.next();
for (int j = 0; j <2; j++) {
if(j==0)
System.out.print(" النظري :");
else
System.out.print(" لعملي:");
b[i][j]=mu.nextInt();
}
}
System.out.println("\n الغياب");
for (i = 0; i < n; i += 1) {
for (int j = 0; j <2; j++) {
if(b[i][1]==0 && b[i][0]==0)
System.out.println(a[i]);break;
}
}
System.out.println("\nادا العملي صفر نطبع درجات النظري");
for (i = 0; i < n; i += 1) {
for (int j = 0; j <2; j++) {
if(b[i][1]==0 && b[i][0]!=0){
System.out.print(a[i]+" :");
System.out.println(b[i][0]);break;
}
}}
System.out.println("\n if 13 or 15 : ");
for (i = 0; i < n; i += 1) {
for (int j = 0; j <2; j++) {
if(b[i][1]>=13){
System.out.print(a[i]+" :");
System.out.print(b[i][1]+"\n");break;
}
}
}
for (int i = 1; i <=6; i++) {
if(i%2==0 && i>1&&i<=5)
System.out.print(i+" "+i);
else if(i%2!=0 && i>1&&i<=5)
System.out.print(" "+i+" "+i);
else
System.out.print(" "+i);
System.out.println("");
}
