What's new

Help Patulong namn

G O Z A R U

Forum Expert
Elite
Joined
Apr 7, 2017
Posts
7,988
Solutions
1
Reaction
4,323
Points
2,361
  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. 🙂
 
pili lng po dyan sa list tulad nyan classes at objects tas Yung output nya. yung code at output lng po need.
 
Last edited by a moderator:
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);
    }
}
 
Last edited:
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;
}
 
Last edited by a moderator:
[XX='Arjien, c: 1130748, m: 1773652'][/XX] hindi po pwedeng null yung return value, ginawa ko nalang pong void.
 
[XX='Arcturus, c: 1130777, m: 565706'][/XX] Depende yan sa gamit mo. Pede naman yung return null at void.
 
Galing nadale mo professor mo nito. be sure lng na alam mo yung mga gamit nila bka ipa debug sayo.
 
Back
Top