0% found this document useful (0 votes)
58 views1 page

Java

This document contains code for a Java program that allows a user to purchase prepaid mobile credit. It includes methods for loading different credit amounts, selecting a mobile network, processing the transaction, and providing change if needed. The code displays menus for loading credit in 20, 50, or 100 peso amounts. It then prompts the user to select a network like Globe, Smart, Sun, or TM. Based on their choices, it calculates the transaction and prints the results.

Uploaded by

Ono Masatoshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views1 page

Java

This document contains code for a Java program that allows a user to purchase prepaid mobile credit. It includes methods for loading different credit amounts, selecting a mobile network, processing the transaction, and providing change if needed. The code displays menus for loading credit in 20, 50, or 100 peso amounts. It then prompts the user to select a network like Globe, Smart, Sun, or TM. Based on their choices, it calculates the transaction and prints the results.

Uploaded by

Ono Masatoshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Ono, Masatoshi

TTh: 13:00 ~ 14:00


Object Oriented Programming

public static void load(){


System.out.println("[1]Load 20Pesos");
System.out.println("[2]Load 50Pesos");
System.out.println("[3]Load 100Pesos");
System.out.println("Your Choice: ");
b=x.nextInt();
payment();
}

package javaapplication1;
import java.util.*;
public class Main {
static int a,b,c,e;
static Scanner x=new Scanner(System.in);
public static void transaction(){
public static void main(String[] args)System.out.println("Enter
{
your cash: ");
network();
c=x.nextInt();
}
while(c<e){
System.out.println("Enter Your Cash: ");
public static void network(){
c=x.nextInt();
System.out.println("Networks");
}
System.out.println("[1]Globe");
System.out.println("Thankyou for purchasing!");
System.out.println("[2]Smart");
System.out.println("Your Change: ");
System.out.println("[3]Sun");
System.out.print(c-e);
System.out.println("[4]TM");
}
System.out.println("Your Choice: ");
public static void payment(){
a=x.nextInt();
switch (b){
switch (a){
case 1:
case 1:
System.out.println("Load 20Pesos");
System.out.println("Globe");
e = 20;
load();
transaction();
break;
break;
case 2:
System.out.println("Smart");
case 2:
load();
System.out.println("Load 50Pesos");
break;
e = 50;
case 3:
transaction();
System.out.println("Sun");
break;
load();
break;
case 3:
case 4:
System.out.println("Load 100Pesos");
System.out.println("TM");
e = 100;
load();
transaction();
break;
break;
default:
default:
System.out.println("No Network");
System.out.println("No Choice");
}
}
}
}
}

You might also like