🔒 Closed Patulong namn

Status
Not open for further replies.
  1. Create a program .Your output MUST HAVE at least two (2) of the following concepts listed below. If you are using a mobile phone, you may use this online Java code compiler: You do not have permission to view the full content of this post. Log in or register now.:
    • User Interfaces
    • Objects
    • Classes
    • Methods
    • Java File Input/Output Manipulation
    • OOP (Inheritance, Encapsulation,
    • Polymorphism) pahelp nmn mga paps kahit dalawa lng dyan sa list. 🙂
 
madali lng yan gawin knowing 2 lang required in incorporate. if you cant do it, then how much more kung mas mahirap na yung ipapagawa sayo
 
sa ngayon nakagawa ako ung methods lng kasi sa CP ko sya ginawa pero Yung iba hirap gawin Kay walang PC kahit manlng laptop sensya Napo🙂
 
Java:
public class Main{
    
    //Method
    public static int getSum(int x, int y){
        return x + y;
    }
    public static void main(String[] args) {
        //Driver for the Object
    Person person = new Person();
    person.setPerson("Arcturus", "Male", "Single", 21);
    person.print();
    System.out.println();
        //Driver for the Method
    System.out.println(getSum(5,3));
    }
}

//Object
class Person {
    String name, gender, marital_status;
    int age;
    public Person(){
        this.name = "";
        this.gender = "";
        this.marital_status = "";
    }
    public void setPerson(String name, String gender, String marital_status, int age){
        this.name = name;
        this.gender = gender;
        this.marital_status = marital_status;
        this.age = age;
    }
    public void print(){
        System.out.printf("Name: %s%nGender: %s%nMarital Status: %s%nAge: %d",this.name, this.gender, this.marital_status, this.age);
    }
}
 
return statement kulang.
public String toString(){
System.out.printf("Name: %s%nGender: %s%nMarital Status: %s%nAge: %d",this.name, this.gender, this.marital_status, this.age);
return null;
}
 
[XX='Arjien, c: 1130748, m: 1773652'][/XX] hindi po pwedeng null yung return value, ginawa ko nalang pong void.
 
[XX='Arcturus, c: 1130739, m: 565706'][/XX] ganito po ba yung output niya
 

Attachments

  • Screenshot_2021-04-26-20-49-32-69_7885c407ff790600b0e797e3f33df4de.webp
    Screenshot_2021-04-26-20-49-32-69_7885c407ff790600b0e797e3f33df4de.webp
    31.4 KB · Views: 20
[XX='Arcturus, c: 1130777, m: 565706'][/XX] Depende yan sa gamit mo. Pede naman yung return null at void.
 
Status
Not open for further replies.

About this Thread

  • 28
    Replies
  • 617
    Views
  • 4
    Participants
Last reply from:
G O Z A R U

Trending Topics

Online now

Members online
683
Guests online
2,032
Total visitors
2,715

Forum statistics

Threads
2,294,716
Posts
29,092,931
Members
1,207,490
Latest member
Pusakalye
Back
Top