Mga lods baka alam niyo icode using java??

Status
Not open for further replies.
Just return itemPrice * ItemQuantity
or
amountDue = itemPrice * itemQuantity
return amountDue
eto lods
1632411220662.webp
 
ano ilalagay sa settotalcost??,nabago kona sa gettotalcost
View attachment 1628017
Sa setTotalCost() dito mo gagawin yung operation.
Java:
public void setTotalCost(double itemPrice, int itemQuantity) {
        this.itemPrice = itemPrice;
        this.itemQuantity = itemQuantity;
        this.amountDue = this.itemPrice * this.itemQuantity;
}

Kung mapapasin mo sa tawag sa kanila dapat alam mo na yung purpose, sa getter dun mo lang kukunin yung value ng variable kaya nga get return value lang, sa setter naman dun mo iseset or ilalagay yung value kaya set.

Sa main class mo gumamit ka ng scanner, gumawa ka ng scanner instance. Stick with the instruction given na din naman yan.
Java:
Scanner s = new Scanner(System.in);
You do not have permission to view the full content of this post. Log in or register now.
 
Sa setTotalCost() dito mo gagawin yung operation.
Java:
public void setTotalCost(double itemPrice, int itemQuantity) {
        this.itemPrice = itemPrice;
        this.itemQuantity = itemQuantity;
        this.amountDue = this.itemPrice * this.itemQuantity;
}

Kung mapapasin mo sa tawag sa kanila dapat alam mo na yung purpose, sa getter dun mo lang kukunin yung value ng variable kaya nga get return value lang, sa setter naman dun mo iseset or ilalagay yung value kaya set.

Sa main class mo gumamit ka ng scanner, gumawa ka ng scanner instance. Stick with the instruction given na din naman yan.
Java:
Scanner s = new Scanner(System.in);
You do not have permission to view the full content of this post. Log in or register now.
dito lods san ako nagkamali?? medj nalito nako dyan eh
1632412372024.webp
 
dito lods san ako nagkamali?? medj nalito nako dyan eh
View attachment 1628018
Sa readInput() nakalagay sa instruction mag lalagay ng input or sa ibang salita mag seset ka ng values dun sa mga variable. Nakuha mo naman yung idea haha mali lang yung implementation.

So sa pag set mo ng value sa variables ano yung gagamitin mo? malamang yung mga setter
Java:
public void readInput(String name, int quanti, double price) {
    setItemName(name);
    setTotalCost(price, quanti)
}
 
dito lods san ako nagkamali?? medj nalito nako dyan eh
View attachment 1628018
Sa writeOutput() naman display lang naman yung output. Since ok na din naman yung mga setter madali nalang yung pag display sakanila. Gagamitin mo dito yung ilang private variables at syempre yung mga getter.
Java:
public void writeOutput() {
    System.out.println("Your are purchasing " + this.itemQuantity + " " + getItemName() + " at " + this.itemPrice + " each.");
    System.out.println("Amount due is " + getTotalCost());
}
 
Sa writeOutput() naman display lang naman yung output. Since ok na din naman yung mga setter madali nalang yung pag display sakanila. Gagamitin mo dito yung ilang private variables at syempre yung mga getter.
Java:
public void writeOutput() {
    System.out.println("Your are purchasing " + this.itemQuantity + " " + getItemName() + " at " + this.itemPrice + " each.");
    System.out.println("Amount due is " + getTotalCost());
}
lods ito sa main ko ano mali ko??
1632413322802.webp
 
paano sir kahit example lang
Java:
import java.util.*;

class main {
    public static void main (String[] args) {
        Scanner s = new Scanner(System.in);
        purchase receipt = new purchase();
       
        System.out.println("Enter the name of the item you are purchasing: ");
        String name = s.nextLine();
        System.out.println("Enter the quantity and price separated by a space: ")
        int quantity = s.nextInt();
        double price = s.nextDouble();
       
        // insert readInput() method here.
        // insert writeInput() method here.
    }
}

You do not have permission to view the full content of this post. Log in or register now.
 
Java:
import java.util.*;

class main {
    public static void main (String[] args) {
        Scanner s = new Scanner(System.in);
        purchase receipt = new purchase();
      
        System.out.println("Enter the name of the item you are purchasing: ");
        String name = s.nextLine();
        System.out.println("Enter the quantity and price separated by a space: ")
        int quantity = s.nextInt();
        double price = s.nextDouble();
      
        // insert readInput() method here.
        // insert writeInput() method here.
    }
}

You do not have permission to view the full content of this post. Log in or register now.
1632416158479.webp

bat may error lods??
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 54
    Replies
  • 4K
    Views
  • 9
    Participants
Last reply from:
Enginer

Online now

Members online
309
Guests online
1,110
Total visitors
1,419

Forum statistics

Threads
2,276,899
Posts
28,972,963
Members
1,230,600
Latest member
mego ken
Back
Top