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
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():
}
}
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("-------------------------------------------------------------");
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