What's new

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

Status
Not open for further replies.
Joined
May 8, 2019
Posts
85
Reaction
9
Points
94
Screenshot_2020-10-22-12-14-00-51_e46acc4301d552178f1fc7f923d8665c.jpg
 

Attachments

Simple lang naman yan ganito:
1. Gumawa ka ng variables para sa softdrinks and sandwich
int softdrinks = 10
int sandwich = 15

2. Gumawa ka ng variables na mag hohold ng number ng order for softdrinks and sandwich
int numberOfSoftdrinks
int numberOfSandwiches

3. Gumawa ka ng variables maghohold ng total value ng softdrinks and sandwich then compute the total for each.
int totalCostOfSoftdrinks
int totalCostOfSandwich
then compute the total:
totalCostOfSoftdrinks = softdrinks * numberOfSoftdrinks
totalCostOfSandwiches = sandwich * numberOfSandwiches

4. Last gumawa ka ng variable para mag hold ng total cost ng softdrinks and sandwich combined.
int totalCost
then compute the total:
totalCost = totalCostOfSoftdrinks + totalCostOfSandwiches

Ayan tulong, ikaw na bahalang bumuo ng program mo.

Things you need to know:
Java Syntax: You do not have permission to view the full content of this post. Log in or register now.
Java Variables: You do not have permission to view the full content of this post. Log in or register now.
Java Operators: You do not have permission to view the full content of this post. Log in or register now.
Java User Input: You do not have permission to view the full content of this post. Log in or register now.
 
Last edited:
Eto example code:

C#:
using System;

using System;
namespace order
{
    class Program
    {
        static void Main(string[] args)
        {
            double softdrinksPrice = 9.5; //I just divided 47.5 by 5
            double sandwichPrice = 24; //same here divided 96 by 4
            double totalSoftDrinks = 0;
            double totalSandwiches = 0;
            double totalPrice = 0;
            int softdrinks = 0;
            int sandwiches = 0;
      
            Console.Write($"How many softdrinks do you want to buy? > ");
            softdrinks = Convert.ToInt32(Console.ReadLine());

            Console.Write($"How many sandwiches do you want to buy? > ");
            sandwiches = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("");

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

            totalPrice = totalSoftDrinks + totalSandwiches;

            Console.WriteLine($"You ordered: {softdrinks} Softdrinks which is cost: Php {softdrinksPrice * softdrinks}");
            Console.WriteLine($"You ordered: {sandwiches} Sandwiches which is cost: Php {sandwichPrice * sandwiches}\n");
            Console.WriteLine($"The Total amount of your Bill is: Php {totalPrice}");
        }
    }
}

OUTPUT:


Code:
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

The Total amount of your Bill is: Php 143.5
 
Last edited:
It's not the price. iba ang result. see my updated answer
Sample lang siguro yung output kung ano yung magiging kalalabasan ng program,
Sabi sa instruction, program that will ask to buy or order a soft drinks and sandwiches, "WHEN" the value of softdrinks = 10 and sandwhich = 15
 
eto magiging result pag ganyan ang price


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
You ordered: 4 Sandwiches which is cost: Php 60

The Total amount of your Bill is: Php 110
 
[XX='zackmark29, c: 417567, m: 77455'][/XX] Yes kasi yun yung nasa instruction, yung expected output, sample lang yun kung ano yung kakalabasan ng program. Buti nalang kung may sinabi sa instruction na, "the output of your program should be the same with the example of expected output".
 
maybe haha pero na sa kanya na yan kung papalitan niya yung price.
ginawa kong sample same as the given example para may idea narin siya
 
Status
Not open for further replies.

Similar threads

Back
Top