What's new

# JavaAmount Due simple program

#### chaekayeon

##### Leecher

Is anyone knows this na papaano gawin ito?

#### FreeAllYouCan-OFFICIAL

##### Leecher
gawin niyo muna yun code.

Elite
San STI ka tol?

#### Licht Bach

Elite
Meron po ako nyan

#### 1nn0c3ntv5

##### Enthusiast
Show ka muna ng ginawa mo check namin dito

#### Licht Bach

Elite
Java:
``````import java.util.Scanner;

class AmmountDue {

Scanner s = new Scanner(System.in);
private final double tax = .12;

public void computeAmmountDue(double price) {
double AddTax = price * tax;
double ammount = price + AddTax;
System.out.println("Amount due is " + ammount);
}

public void computeAmmountDue(double price, int quantity) {
double AddTax = price * tax;
double ammount = (price * quantity) + AddTax;
System.out.println("Amount due is " + ammount);
}

public void computeAmmountDue(double price, int quantity, double discount) {
double AddTax = price * tax;
double ammount = ((price * quantity) - discount) + AddTax;
System.out.println("Amount due is " + ammount);
}

}

public class RunAmmountDue {

public static void main(String[] args) {
int num;
Scanner s = new Scanner(System.in);
AmmountDue due = new AmmountDue();
System.out.println("Press any of the then enter values sepaated by spaces: ");
System.out.println("1  -  Price only");
System.out.println("2  -  Price, Quantity");
System.out.println("3  -  Price, Quantity, and discount amount");
num = s.nextInt();
switch (num) {
case 1:
due.computeAmmountDue(s.nextDouble());
break;
case 2:
due.computeAmmountDue(s.nextDouble(), s.nextInt());
break;
case 3:
due.computeAmmountDue(s.nextDouble(), s.nextInt(), s.nextDouble());
break;
default:
System.out.println("Invalid Input");
break;
}
}
}``````

#### chaekayeon

##### Leecher
Java:
``````import java.util.Scanner;

class AmmountDue {

Scanner s = new Scanner(System.in);
private final double tax = .12;

public void computeAmmountDue(double price) {
double AddTax = price * tax;
double ammount = price + AddTax;
System.out.println("Amount due is " + ammount);
}

public void computeAmmountDue(double price, int quantity) {
double AddTax = price * tax;
double ammount = (price * quantity) + AddTax;
System.out.println("Amount due is " + ammount);
}

public void computeAmmountDue(double price, int quantity, double discount) {
double AddTax = price * tax;
double ammount = ((price * quantity) - discount) + AddTax;
System.out.println("Amount due is " + ammount);
}

}

public class RunAmmountDue {

public static void main(String[] args) {
int num;
Scanner s = new Scanner(System.in);
AmmountDue due = new AmmountDue();
System.out.println("Press any of the then enter values sepaated by spaces: ");
System.out.println("1  -  Price only");
System.out.println("2  -  Price, Quantity");
System.out.println("3  -  Price, Quantity, and discount amount");
num = s.nextInt();
switch (num) {
case 1:
due.computeAmmountDue(s.nextDouble());
break;
case 2:
due.computeAmmountDue(s.nextDouble(), s.nextInt());
break;
case 3:
due.computeAmmountDue(s.nextDouble(), s.nextInt(), s.nextDouble());
break;
default:
System.out.println("Invalid Input");
break;
}
}
}``````

Iniba ko sa akin but it's almost similar to yours po!

#### EYSA

##### Leecher
Java:
``````import java.util.Scanner;

class AmmountDue {

Scanner s = new Scanner(System.in);
private final double tax = .12;

public void computeAmmountDue(double price) {
double AddTax = price * tax;
double ammount = price + AddTax;
System.out.println("Amount due is " + ammount);
}

public void computeAmmountDue(double price, int quantity) {
double AddTax = price * tax;
double ammount = (price * quantity) + AddTax;
System.out.println("Amount due is " + ammount);
}

public void computeAmmountDue(double price, int quantity, double discount) {
double AddTax = price * tax;
double ammount = ((price * quantity) - discount) + AddTax;
System.out.println("Amount due is " + ammount);
}

}

public class RunAmmountDue {

public static void main(String[] args) {
int num;
Scanner s = new Scanner(System.in);
AmmountDue due = new AmmountDue();
System.out.println("Press any of the then enter values sepaated by spaces: ");
System.out.println("1  -  Price only");
System.out.println("2  -  Price, Quantity");
System.out.println("3  -  Price, Quantity, and discount amount");
num = s.nextInt();
switch (num) {
case 1:
due.computeAmmountDue(s.nextDouble());
break;
case 2:
due.computeAmmountDue(s.nextDouble(), s.nextInt());
break;
case 3:
due.computeAmmountDue(s.nextDouble(), s.nextInt(), s.nextDouble());
break;
default:
System.out.println("Invalid Input");
break;
}
}
}``````
YOU SAVED ME

#### EYSA

##### Leecher
Java:
``````import java.util.Scanner;

class AmmountDue {

Scanner s = new Scanner(System.in);
private final double tax = .12;

public void computeAmmountDue(double price) {
double AddTax = price * tax;
double ammount = price + AddTax;
System.out.println("Amount due is " + ammount);
}

public void computeAmmountDue(double price, int quantity) {
double AddTax = price * tax;
double ammount = (price * quantity) + AddTax;
System.out.println("Amount due is " + ammount);
}

public void computeAmmountDue(double price, int quantity, double discount) {
double AddTax = price * tax;
double ammount = ((price * quantity) - discount) + AddTax;
System.out.println("Amount due is " + ammount);
}

}

public class RunAmmountDue {

public static void main(String[] args) {
int num;
Scanner s = new Scanner(System.in);
AmmountDue due = new AmmountDue();
System.out.println("Press any of the then enter values sepaated by spaces: ");
System.out.println("1  -  Price only");
System.out.println("2  -  Price, Quantity");
System.out.println("3  -  Price, Quantity, and discount amount");
num = s.nextInt();
switch (num) {
case 1:
due.computeAmmountDue(s.nextDouble());
break;
case 2:
due.computeAmmountDue(s.nextDouble(), s.nextInt());
break;
case 3:
due.computeAmmountDue(s.nextDouble(), s.nextInt(), s.nextDouble());
break;
default:
System.out.println("Invalid Input");
break;
}
}
}``````
Marunong ka nung code sa fruit basket?

#### EYSA

##### Leecher
Java:
``````import java.util.Scanner;

class AmmountDue {

Scanner s = new Scanner(System.in);
private final double tax = .12;

public void computeAmmountDue(double price) {
double AddTax = price * tax;
double ammount = price + AddTax;
System.out.println("Amount due is " + ammount);
}

public void computeAmmountDue(double price, int quantity) {
double AddTax = price * tax;
double ammount = (price * quantity) + AddTax;
System.out.println("Amount due is " + ammount);
}

public void computeAmmountDue(double price, int quantity, double discount) {
double AddTax = price * tax;
double ammount = ((price * quantity) - discount) + AddTax;
System.out.println("Amount due is " + ammount);
}

}

public class RunAmmountDue {

public static void main(String[] args) {
int num;
Scanner s = new Scanner(System.in);
AmmountDue due = new AmmountDue();
System.out.println("Press any of the then enter values sepaated by spaces: ");
System.out.println("1  -  Price only");
System.out.println("2  -  Price, Quantity");
System.out.println("3  -  Price, Quantity, and discount amount");
num = s.nextInt();
switch (num) {
case 1:
due.computeAmmountDue(s.nextDouble());
break;
case 2:
due.computeAmmountDue(s.nextDouble(), s.nextInt());
break;
case 3:
due.computeAmmountDue(s.nextDouble(), s.nextInt(), s.nextDouble());
break;
default:
System.out.println("Invalid Input");
break;
}
}
}``````
import java.util.Scanner;
import java.util.Stack;

public class fruitbasket1{

public static void main(String[] args){
Scanner eyy = new Scanner(System.in);
Stack<String>basket = new Stack<String>();

String a = "Apple";
String o = "Orange";
String m = "Mango";
String g = "Guava";

System.out.println("Catch and eat any of these fruits; ('apple),('mango'),('orange'),('orange')");
System.out.print("How many fruits would you like to catch: ");
int num = eyy.nextlnt();
for(int i = 0;i<=num;i++){
System.out.println("Fruits"+i+"of"+num);
char f = eyy.next().charAt(0);
if(f.equals("a")){
Basket.push(a);
}else if(f.equals("o")){
Basket.push(o);
}else if(f.equals("m")){
Basket.push(m);
}else if (f.equals("g")){
Basket.push(g);
}else{
System.out.println("Not Available");
}
}
System.out.println("Your basket now has:" + Basket);
System.out.print("Press E to eat fruit: ");

while(true){
char e = eyy.next().charAt(0);
if(e == 'e'){
Basket.pop();
}
System.out.println("Fruit(s) in the basket:" + Basket);
System.out.print("Press E to eat fruit: ");
if(Basket.isEmpty()){
System.out.println("MO MORE FRUITS");
break;
}
System.out.println("Fruit(s) in the basket:" + Basket);
System.out.print("Press E to eat fruit: ");
}
}
}

pa ask anong mali

#### Licht Bach

Elite
import java.util.Scanner;
import java.util.Stack;

public class fruitbasket1{

public static void main(String[] args){
Scanner eyy = new Scanner(System.in);
Stack<String>basket = new Stack<String>();

String a = "Apple";
String o = "Orange";
String m = "Mango";
String g = "Guava";

System.out.println("Catch and eat any of these fruits; ('apple),('mango'),('orange'),('orange')");
System.out.print("How many fruits would you like to catch: ");
int num = eyy.nextlnt();
for(int i = 0;i<=num;i++){
System.out.println("Fruits"+i+"of"+num);
char f = eyy.next().charAt(0);
if(f.equals("a")){
Basket.push(a);
}else if(f.equals("o")){
Basket.push(o);
}else if(f.equals("m")){
Basket.push(m);
}else if (f.equals("g")){
Basket.push(g);
}else{
System.out.println("Not Available");
}
}
System.out.println("Your basket now has:" + Basket);
System.out.print("Press E to eat fruit: ");

while(true){
char e = eyy.next().charAt(0);
if(e == 'e'){
Basket.pop();
}
System.out.println("Fruit(s) in the basket:" + Basket);
System.out.print("Press E to eat fruit: ");
if(Basket.isEmpty()){
System.out.println("MO MORE FRUITS");
break;
}
System.out.println("Fruit(s) in the basket:" + Basket);
System.out.print("Press E to eat fruit: ");
}
}
}

pa ask anong mali
yung sa for loops mo paps +1 mo dapat yung i para 1 of 4 yung lalabasbas
basket yung declare mo pero Basket nilagay mo

ung sa press e ns input lagay mo dapat sa loob ng while loops mo para di na kailangan ulitin yung press e ng system out
Lagay mo lang sa while(!basket.isEmpty){
laman ng basket
}

#### Licht Bach

Elite
yung sa for loops mo paps +1 mo dapat yung i para 1 of 4 yung lalabasbas
basket yung declare mo pero Basket nilagay mo

ung sa press e ns input lagay mo dapat sa loob ng while loops mo para di na kailangan ulitin yung press e ng system out
Lagay mo lang sa while(!basket.isEmpty){
laman ng basket
}
Code:
``````import java.util.Scanner;
import java.util.Stack;

public class fruitbasket1 {

public static void main(String[] args) {
Scanner eyy = new Scanner(System.in);
Stack basket = new Stack();

String a = "Apple";
String o = "Orange";
String m = "Mango";
String g = "Guava";

System.out.println("Catch and eat any of these fruits; ('apple),('mango'),('orange'),('orange')");
System.out.print("How many fruits would you like to catch: ");
int num = eyy.nextInt();

for (int x = 0; x < num; x++) {
int xx = x + 1;
System.out.print("Fruit " + xx + " of " + num + ": ");
char fr = eyy.next().charAt(0);
eyy.nextLine();
String sfr = String.valueOf(fr);//Convert char to string
if (sfr.equalsIgnoreCase("A")) {
basket.push(a);
} else if (sfr.equalsIgnoreCase("O")) {
basket.push(o);
} else if (sfr.equalsIgnoreCase("M")) {
basket.push(m);
} else if (sfr.equalsIgnoreCase("G")) {
basket.push(g);
}
}

System.out.println("Your basket now has:" + basket);

while (true) {
System.out.print("Press E to eat fruit: ");
char e = eyy.next().charAt(0);
eyy.nextLine();
if (e == 'e') {
basket.pop();
while (!basket.isEmpty()) {
System.out.println("Fruit(s) in the basket:" + basket);
break;
}
}
if (basket.isEmpty()) {
System.out.println("MO MORE FRUITS");
break;
}

}
}
}``````

#### EYSA

##### Leecher
yung sa for loops mo paps +1 mo dapat yung i para 1 of 4 yung lalabasbas
basket yung declare mo pero Basket nilagay mo

ung sa press e ns input lagay mo dapat sa loob ng while loops mo para di na kailangan ulitin yung press e ng system out
Lagay mo lang sa while(!basket.isEmpty){
laman ng basket
}
wahh moms ako hahaha hindi paps may socmeds kaba? pahinge pm kita haha

Replies
2
Views
149
Replies
5
Views
103
Replies
1
Views
120
Replies
15
Views
235
Replies
8
Views
331

Members online
630
Guests online
497
Total visitors
1,127

### Forum statistics

Threads
1,437,141
Posts
23,679,864
Members
1,727,545
Latest member
ardurscorporation
Attachments
2,075,222
Profile posts
103,638