What's new

Closed Java language po ..baka may gusto tumulong ❤️

Status
Not open for further replies.
[XX='zackmark29, c: 417615, m: 77455'][/XX] hahaha boss maling room po ata na pasukan niyo, dun po dapat ata kayo sa kabila wala ka sa lista 😅
 
Ok eto na java version ahaha nakapag-aral tuloy ako ng java

C# VERSION NASA TAAS =D

JAVA VERSION:

Java:
public class test {

     public static void main(String []args){
       var input = new Scanner(System.in)
        double softdrinksPrice = 10; // or sa given example 9.5
        double sandwichPrice = 15; // or sa given example 24
        double totalSoftDrinks = 0;
        double totalSandwiches = 0;
        double totalPrice = 0;
        int softdrinks = 0;
        int sandwiches = 0;

        System.out.println("Softdrinks price: " + softdrinksPrice );
        System.out.println("Sandwich price: " + sandwichPrice  + "\n");

        System.out.print(String.format("How many softdrinks do you want to buy? > "));
        softdrinks = input.nextInt();

        System.out.print(String.format("How many sandwiches do you want to buy? > "));
        sandwiches = input.nextInt();
        System.out.println("");

        totalSoftDrinks = softdrinksPrice * softdrinks;
        totalSandwiches = sandwichPrice * sandwiches;
        totalPrice = totalSoftDrinks + totalSandwiches;

        System.out.println(String.format("You ordered: %1$s Softdrinks which is cost: Php %2$s", softdrinks, totalSoftDrinks));
        System.out.println(String.format("You ordered: %1$s Sandwiches which is cost: Php %2$s\n", sandwiches, totalSandwiches));
        System.out.println(String.format("The Total amount of your Bill is: Php %1$s", totalPrice));

       input.close():
     }
}

RESULT for given example:
Softdrinks price: 9.5
Sandwich price: 24

How many softdrinks do you want to buy? > 5
How many sandwiches do you want to buy? > 4

You ordered: 5 Softdrinks which is cost: Php 47.5
You ordered: 4 Sandwiches which is cost: Php 96.0

The Total amount of your Bill is: Php 143.5

RESULT for given instruction:
Softdrinks price: 10
Sandwich price: 15

How many softdrinks do you want to buy? > 5
How many sandwiches do you want to buy? > 4

You ordered: 5 Softdrinks which is cost: Php 50.0
You ordered: 4 Sandwiches which is cost: Php 60.0

The Total amount of your Bill is: Php 110.0
 
Last edited:
Java:
package test;
import java.util.Scanner;

public class PabiliPo {
    public static void main(String[] args) {
    Scanner input = new Scanner(System.in);

    int softdrinks = 10, sandwich = 15;
    int numberOfSoftDrinks, numberOfSandwiches;
    int totalCost, totalCostOfSoftdrinks, totalCostOfSandwich;

    System.out.print("How many softdrinks do you want to buy: ");
    numberOfSoftDrinks = input.nextInt();
    System.out.print("How many sandwich do you want to buy: ");
    numberOfSandwiches = input.nextInt();

    totalCostOfSoftdrinks = softdrinks * numberOfSoftDrinks;
    System.out.println("You ordered: " + numberOfSoftDrinks + " softdrinks which costs: " + totalCostOfSoftdrinks);
    totalCostOfSandwich = sandwich * numberOfSandwiches;
    System.out.println("You ordered: " + numberOfSandwiches + " sandwich which costs: " + totalCostOfSandwich);

    totalCost = totalCostOfSoftdrinks + totalCostOfSandwich;
    System.out.print("The total amount of your bill is: Php " + totalCost);

    }
}

Ganito na talaga 😅

test run2.PNG
 

Attachments

yung comment mo sa taas na java yun yung error

errorrrrrrrrrrrr.PNG

JAVA VERSION:

Java:
public class test {

     public static void main(String []args){
       var input = new Scanner(System.in)
        double softdrinksPrice = 10; // or sa given example 9.5
        double sandwichPrice = 15; // or sa given example 24
        double totalSoftDrinks = 0;
        double totalSandwiches = 0;
        double totalPrice = 0;
        int softdrinks = 0;
        int sandwiches = 0;

        System.out.println("Softdrinks price: " + softdrinksPrice );
        System.out.println("Sandwich price: " + sandwichPrice  + "\n");

        System.out.print(String.format("How many softdrinks do you want to buy? > "));
        softdrinks = input.nextInt();

        System.out.print(String.format("How many sandwiches do you want to buy? > "));
        sandwiches = input.nextInt();
        System.out.println("");

        totalSoftDrinks = softdrinksPrice * softdrinks;
        totalSandwiches = sandwichPrice * sandwiches;
        totalPrice = totalSoftDrinks + totalSandwiches;

        System.out.println(String.format("You ordered: %1$s Softdrinks which is cost: Php %2$s", softdrinks, totalSoftDrinks));
        System.out.println(String.format("You ordered: %1$s Sandwiches which is cost: Php %2$s\n", sandwiches, totalSandwiches));
        System.out.println(String.format("The Total amount of your Bill is: Php %1$s", totalPrice));

       input.close():
     }
}
 

Attachments

import java.util.Scanner;
class MainClass {
public static void main(String[]args)
{
Scanner sc = new Scanner(System.in);
System.out.print("How many softdrinks you want to buy: ");
int softdrink = sc.nextInt();
System.out.print("How many sandwich you want to buy: ");
int sandwich = sc.nextInt();
int total_softdrink = softdrink*10;
int total_sandwich = sandwich*15;
System.out.println("You ordered: " + softdrink +" Softdrinks and it cost: "+ total_softdrink);
System.out.println("You ordered: " + sandwich +" Sandwich and it cost: "+ total_sandwich);
float total= total_softdrink+total_sandwich;
System.out.println("The total amount of your bill is: php "+ total);
System.out.println("-------------------------------------------------------------");


}
}
 
Last edited:
Basic lang to ehh , kung talagang mga programmer kayo dapat di nyo siya bibigyan ng code . Hayaan nyo syang gumawa at itama yung mali nya hindi yung ibibigay nyo nalang yung code pano yan matututo ? Kung talagang matulungin kayo , tulungan nyo yung taong matuto at hindi tulungang maging tamad
 
Status
Not open for further replies.

Similar threads

Back
Top