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 static void main(String[] args){
Scanner eyy = new Scanner(System.in);

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")){
}else if(f.equals("o")){
}else if(f.equals("m")){
}else if (f.equals("g")){
}else{
System.out.println("Not Available");
}
}
System.out.print("Press E to eat fruit: ");

while(true){
char e = eyy.next().charAt(0);
if(e == 'e'){
}
System.out.print("Press E to eat fruit: ");
System.out.println("MO MORE FRUITS");
break;
}
System.out.print("Press E to eat fruit: ");
}
}
}

#### Licht Bach

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

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

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")){
}else if(f.equals("o")){
}else if(f.equals("m")){
}else if (f.equals("g")){
}else{
System.out.println("Not Available");
}
}
System.out.print("Press E to eat fruit: ");

while(true){
char e = eyy.next().charAt(0);
if(e == 'e'){
}
System.out.print("Press E to eat fruit: ");
System.out.println("MO MORE FRUITS");
break;
}
System.out.print("Press E to eat fruit: ");
}
}
}

yung sa for loops mo paps +1 mo dapat yung i para 1 of 4 yung lalabasbas

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
}

#### Licht Bach

Elite
yung sa for loops mo paps +1 mo dapat yung i para 1 of 4 yung lalabasbas

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
}
Code:
``````import java.util.Scanner;
import java.util.Stack;

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

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")) {
} else if (sfr.equalsIgnoreCase("O")) {
} else if (sfr.equalsIgnoreCase("M")) {
} else if (sfr.equalsIgnoreCase("G")) {
}
}

while (true) {
System.out.print("Press E to eat fruit: ");
char e = eyy.next().charAt(0);
eyy.nextLine();
if (e == 'e') {
break;
}
}
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

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
}
wahh moms ako hahaha hindi paps may socmeds kaba? pahinge pm kita haha

Replies
2
Views
181
Replies
5
Views
113
Replies
2
Views
169
Replies
15
Views
235
Replies
10
Views
398

Members online
1,874
Guests online
1,145
Total visitors
3,019