java Application Convert to java Applet

java Application Convert to java Applet

Hi every Java Masters i'm Java beginner ,and i want below this figures source code convert to Java Applet hope every Masters can helping thank .

import java.util.*; import java.text.*;

class RCars{ public static void main(String[] args){

DecimalFormat df = new DecimalFormat("$##.##");

Scanner input = new Scanner(System.in);

int day=0;

int menu = 0;

boolean quit = false; do{

System.out.println(" Welcome to Rental Car System ");

System.out.println(" **********");

//System.out.print("\n");

System.out.println("Car Menu");

System.out.println(" ");

System.out.println("1. Honda City " );

System.out.println("2. Toyota Vios");

System.out.println("3. Nissan Latio");

System.out.println("4. Exit");

System.out.print("\n");

System.out.print("Please enter your choice: ");

menu = input.nextInt();

System.out.println();

switch(menu) {

case 1:

System.out.print("Enter Number of Day : ");

day = input.nextInt();

System.out.print("\n");

System.out.println("**Rental Car Charges**");

System.out.println("Vehicle type= Honda City " + " Deposit Rm100.00 " + " Daily Rate 60 " + " rent " + day + " day ");

if(day>0){

double amount=(day-0)*60.00 + 100.00;

System.out.println("Rental Total Charges= "+df.format(amount));

System.out.println("");

System.out.print("Do you want to continue next Process?( y/n ): ");

String dec = input.next();

if (dec.equals("y")) {

System.out.println("");

System.out.println("Enter Customer Name: ");

String name = input.next();

System.out.println("");

System.out.println("Enter IC Number: ");

String num = input.next();

System.out.println("");

System.out.println("Enter Age : ");

String Age = input.next();

System.out.println("");

System.out.println("Enter Mobile Phone Number: ");

String Phone = input.next();

System.out.println("");

System.out.println("Enter Credit Card Number ");

String Ccard = input.next();

System.out.println("");

System.out.println();

System.out .println(" Customer Name " + " IC Number " + " Age " + " Mobile Phone Number " + " Rental Charger ");

System.out.println(" "+ name + " " + num + " " + " " + Age + " " + " " + Phone + " " + df.format(amount) ); System.out.println();

System.out.print("\n");

}

else{

System.out.print("\n");

System.out.println(" Thank survey to Rental Car System and See you Again....!");

System.out.print("\n"); } } break; case 2:

System.out.print("Enter Number of Day : ");

day = input.nextInt();

System.out.println("**Rental Car Charges**");

System.out.println("Vehicle type= Car");

if(day>0){

double amount=(day-0)*60.00 + 100.00;

System.out.println("Rental Total Charges= "+df.format(amount));

System.out.print("Continue Proceed to rent?( y/n ): ");

String dec = input.next();

if (dec.equals("y")) {

System.out.println("Enter Customer Name: ");

String name = input.next();

System.out.println("Enter IC Number: ");

String num = input.next();

System.out.println("Enter Age : ");

String Age = input.next();

System.out.println("Enter Mobile Phone Number: ");

String Phone = input.next();

System.out.print("\n");

System.out .println(" Customer Name " + " IC Number " + " Age " + " Mobile Phone Number " + " Rental Charger ");

System.out.println(" "+ name + " " + num + " " + " " + Age + " " + " " + Phone + " " + df.format(amount) ); System.out.print("\n"); }

else{

System.out.print("\n");

System.out.println(" See you Again....!");

System.out.print("\n"); } } break;

case 3:

System.out.print("Enter Number of Day : ");

day = input.nextInt();

System.out.println("**Rental Car Charges**");

System.out.println("Vehicle type= Bus/Truck");

if(day>0){

double amount=(day-0)*60.00 + 100.00;

System.out.println("Rental Total Charges= "+df.format(amount));

System.out.print("Continue Proceed to rent?( y/n ): ");

String dec = input.next();

if (dec.equals("y")) {

System.out.println("Enter Customer Name: ");

String name = input.next();

System.out.println("Enter IC Number: ");

String num = input.next();

System.out.println("Enter Age : ");

String Age = input.next();

System.out.println("Enter Mobile Phone Number: ");

String Phone = input.next();

System.out.print("\n");

System.out .println(" Customer Name " + " IC Number " + " Age " + " Mobile Phone Number " + " Rental Charger ");

System.out.println(" "+ name + " " + num + " " + " " + Age + " " + " " + Phone + " " + df.format(amount) );

System.out.print("\n"); }

else{

System.out.print("\n");

System.out.println(" See you Again....!");

System.out.print("\n"); } }

break;

case 4:

quit = true;

break;

default:

System.out.println("Invalid Entry!"); } }

while (!quit); } }

View Answers

April 15, 2011 at 4:35 PM

import javax.swing.*;
import java.applet.*;
import java.awt.*;
import java.util.*;
import java.text.*;
import java.awt.event.*;

public class RCars extends Applet implements ActionListener{
  TextField text,text1,text2,text3,text4;
  Label label1,label2,label3,label4,label5,label6;
  Label lab;
  Button b1,b2;
  JComboBox combo;
  DecimalFormat df = new DecimalFormat("$##.##");
  public void init(){
    setLayout(null);

    lab=new Label("Welcome to Rental Car System");
    lab.setBounds(100,20,200,20);
    add(lab);

    label1 = new Label("Select Type of Car: ");
    label1.setBounds(20,50,180,20);
    add(label1);
    combo=new JComboBox();
    combo.addItem("--Select--");
    combo.addItem("Honda City");
    combo.addItem("Toyota Vios");
    combo.addItem("Nissan Latio");
    combo.setBounds(200,50,120,20);
    add(combo);
    label2 = new Label("Enter number of days: ");
    label2.setBounds(20,80,180,20);
    add(label2);

    text = new TextField(5);
    text.setBounds(200,80,100,20);
    add(text);

    b1 = new Button("Submit");
    b1.setBounds(200,140,100,20);
    add(b1);
    b1.addActionListener(this);

    label3=new Label("Enter Customer Name: ");
    label3.setBounds(20,60,180,20);
    add(label3);

    text1=new TextField(10);
    text1.setBounds(200,60,100,20);
    add(text1);

    label4=new Label("Enter IC Number: ");
    label4.setBounds(20,90,180,20);
    add(label4);

    text2=new TextField(10);
    text2.setBounds(200,90,100,20);
    add(text2);

    label5=new Label("Enter Age: ");
    label5.setBounds(20,120,180,20);
    add(label5);

    text3=new TextField(10);
    text3.setBounds(200,120,100,20);
    add(text3);

    label6=new Label("Enter Mobile Number: ");
    label6.setBounds(20,150,180,20);
    add(label6);

    text4=new TextField(10);
    text4.setBounds(200,150,100,20);
    add(text4);

    b2=new Button("Submit");
    b2.setBounds(200,180,100,20);
    add(b2);
    label3.setVisible(false);
    label4.setVisible(false);
    label5.setVisible(false);
    label6.setVisible(false);
    text1.setVisible(false);
    text2.setVisible(false);
    text3.setVisible(false);
    text4.setVisible(false);
    b2.setVisible(false);
     }

April 15, 2011 at 4:37 PM

continue..

    public void actionPerformed(ActionEvent ae){
    String value=combo.getSelectedItem().toString();
    int day=Integer.parseInt(text.getText());
    if(value.equals("Honda City")){
        if(day>0){
   final double amount=(day-0)*60.00 + 100.00;
    JOptionPane.showMessageDialog(null,"Vehicle type= Honda City \n" + " Deposit= Rm100 \n " + " Daily Rate= 60 \n" + "days= " + day+"\n\n"+"Rental Total Charges= "+df.format(amount));
    String st=JOptionPane.showInputDialog(null,"Do you want to continue next Process?( y/n ): ");
    if(st.equals("y")){
    label1.setVisible(false);
    label2.setVisible(false);
    text.setVisible(false);
    combo.setVisible(false);
    b1.setVisible(false);
    b2.setVisible(true);
    label3.setVisible(true);
    label4.setVisible(true);
    label5.setVisible(true);
    label6.setVisible(true);
    text1.setVisible(true);
    text2.setVisible(true);
    text3.setVisible(true);
    text4.setVisible(true);
    b2.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
    JOptionPane.showMessageDialog(null," Customer Name: " +text1.getText()+ "\n IC Number: " +text2.getText()+ "\n Age: " +text3.getText()+ "\n Mobile Number: " +text4.getText()+ "\n Rental Charger:  "+ df.format(amount) );
        }
    });
    }
    else{
        JOptionPane.showMessageDialog(null,"Thank survey to Rental Car System and See you Again....!");
    }
    }
    }
    else if(value.equals("Toyota Vios")){
        if(day>0){
   final double amount=(day-0)*60.00 + 100.00;
    JOptionPane.showMessageDialog(null,"Vehicle type= Honda City \n" + " Deposit= Rm100 \n " + " Daily Rate= 60 \n" + "days= " + day+"\n\n"+"Rental Total Charges= "+df.format(amount));
    String st=JOptionPane.showInputDialog(null,"Do you want to continue next Process?( y/n ): ");
    if(st.equals("y")){
    label1.setVisible(false);
    label2.setVisible(false);
    text.setVisible(false);
    combo.setVisible(false);
    b1.setVisible(false);
    b2.setVisible(true);
    label3.setVisible(true);
    label4.setVisible(true);
    label5.setVisible(true);
    label6.setVisible(true);

    text1.setVisible(true);
    text2.setVisible(true);
    text3.setVisible(true);
    text4.setVisible(true);
b2.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
    JOptionPane.showMessageDialog(null," Customer Name: " +text1.getText()+ "\n IC Number: " +text2.getText()+ "\n Age: " +text3.getText()+ "\n Mobile Number: " +text4.getText()+ "\n Rental Charger:  "+ df.format(amount) );
        }
    }); }
    else{
        JOptionPane.showMessageDialog(null,"Thank survey to Rental Car System and See you Again....!");
    }
    }
    }

April 15, 2011 at 4:37 PM

continue..

else if(value.equals("Nissan Latio")){
        if(day>0){
   final double amount=(day-0)*60.00 + 100.00;
    JOptionPane.showMessageDialog(null,"Vehicle type= Honda City \n" + " Deposit= Rm100 \n " + " Daily Rate= 60 \n" + "days= " + day+"\n\n"+"Rental Total Charges= "+df.format(amount));
    String st=JOptionPane.showInputDialog(null,"Do you want to continue next Process?( y/n ): ");
    if(st.equals("y")){
    label1.setVisible(false);
    label2.setVisible(false);
    text.setVisible(false);
    combo.setVisible(false);
    b1.setVisible(false);
    b2.setVisible(true);
    label3.setVisible(true);
    label4.setVisible(true);
    label5.setVisible(true);
    label6.setVisible(true);

    text1.setVisible(true);
    text2.setVisible(true);
    text3.setVisible(true);
    text4.setVisible(true);
b2.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
    JOptionPane.showMessageDialog(null," Customer Name: " +text1.getText()+ "\n IC Number: " +text2.getText()+ "\n Age: " +text3.getText()+ "\n Mobile Number: " +text4.getText()+ "\n Rental Charger:  "+ df.format(amount) );
        }
    }); }
    else{
        JOptionPane.showMessageDialog(null,"Thank survey to Rental Car System and See you Again....!");
    }
    }
    }
    }
}

April 16, 2011 at 8:12 PM

But Java Master if i finishto to Sumit value how can i return back to car seletion function ? if it using " return true " source to put somewhere ? and thank for helping to covert all this application ..









Related Tutorials/Questions & Answers:
convert java Application to Java Applet
convert java Application to Java Applet  hi every Java Master or Java Professional , my Name Is Vincent i'm java beginner can i ask a question regarding for Java application convert to Java Applet. below her is my sample
java Application Convert to java Applet
java Application Convert to java Applet  Hi every Java Masters i'm Java beginner ,and i want below this figures source code convert to Java Applet hope every Masters can helping thank . import java.util.*; import java.text.
Advertisements
convert java Application to Java Applet
convert java Application to Java Applet  hi every Java Master or Java Professional , my Name Is Vincent i'm java beginner can i ask a question regarding for Java application convert to Java Applet. below her is my sample
java Application to java Applet
java Application to java Applet  sorry Java master disturb again how can i modify below this Java application to applet because in swtich case i had put this countinue selection source code to make user choosing so hope can
java application - Applet
java application  codes in repetition and decision  codes in repition and decision
java application/applet - Java Beginners
java application/applet  In this project, the student has to develop and submit a program for a Java application / applet which contains a set of GUI components as detailed below. 1. The Java applet page/application models
Java Application change to java applet
Java Application change to java applet   Hi every Java Masters i'm Java beginner ,and i want below this figures source code convert to Java Applet... extends Applet implements ActionListener{ TextField text,output; Label
how to convert java Applet to Jave Frame
how to convert java Applet to Jave Frame  hi every java master or Java Professional my name is vincent i'm java beginners hope u all can ,tech me how to convert Java Applet to Jave Frame below this code is my applet source code
java applet - Applet
java applet  wants to creat address bar on my java applet.  Hi Applet don't provide a facility to create a address bar directly. You just create a text box. In this text box if you enter any http address
loading Java Applet - Applet
loading Java Applet  Hi, I use the archive tag to download my applet into the Browser It takes too long to load. Can I do it in several steps... control the loading within the applet? thanks
Java Applet
Java Applet   How to add Image in Java Applet? what is getDocumentBase
java applet - Applet
java applet  I want to close applet window which is open by another button of applet program. plz tell me!   Hi Friend, Try...://www.roseindia.net/java/example/java/applet/ Thanks
java - Applet
java  how to connect database table with scrollbar in java applet
java - Applet
java  how to connect database table with scrollbar in java applet
java - Applet
java  what is applet?  Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/applet/ Thanks
Convert - Applet
Convert   Hello dear colleques I would like to ask about some converting program currently i am doing converting program my graduation report. I came from mongolia and I live in korea now. therefore my supevisor gave
java applet
java applet  why java applet programs doesn't contain main method
java applet
java applet  why java applet programs doesn't contain main method
java applet problem - Applet
java applet problem  i was doing a program using java applet. I want... and to exit from the applet respectively.Now i want to display a message when...*; import java.awt.*; public class Calculator extends Applet implements
Java applet
Java applet  What tags are mandatory when creating HTML to display an applet
Java applet
Java applet   How do I go from my applet to another JSP or HTML page
java applet
java applet  If i insert in database from applet this work, but from applet.html don't
Java Applet
Java Applet  Hi, What is Java Applet and how it can be useful in development of Java programs? Can anyone tell me the url to learn Java Applet? Thanks   Hi, See the tutorial at: Applications and Applets Thanks
java - Applet
java  how to communicate to my servlet through applet.   ... this information to the servlet in the normal way. The applet pretends... is concerned, the applet is just another HTTP client. For more infomation
java applet
java applet   I want code to implement (1) user will enter how many nodes (2)it should allow that no. of clicks and circle should be displayed at that position
java - Applet
java  what is applet
Applet Application
Applet Application  import java.awt.*; import java.applet.*; class pawan extends Applet { public static void main(String args...(); } } <APPLET WIDTH=1000 HEIGTH=800 </APPLET>
java applet
java applet  Creation of Applet for Personal Details Form When a customer places his first order of garments, the Personal Details Form is displayed.... The applet must include the following validations: ï?® The FirstName, Address1
The Java Applet Viewer
The Java Applet Viewer       Applet viewer is a command line program to run Java applets...; the browser should be Java enabled.To create an applet, we need to define
java applet prog
java applet prog  applet to display scrolling text from right to left in an applet window using thread. text should be accepted by html parameter
java - Applet
java  i have button browse button in my applet form.when i click on browse button i have to go to file storage box(what ever files stored in my... in the mail).i have display that file path in my applet form.am learner please send me
java - Applet
java  1.An applet program to draw a line graph for y=2x+5.[for suitable values of x & y] 2. An applet program to draw following shapes (1)cone... java.applet.Applet; public class CubeExample extends Applet { Stroke
Java applet
Java applet  How do I determine the width and height of my application
java applet
java applet  create applets to accept the personal details and sales details in the database. create jdbc application to connect the applets with the database
java - Applet
java  Hi, I need very urgent code............ please help me......... How to convert text to wave conversion? I need java code............ Regards, Valarmathi
Java applet
Java applet  What is AppletStub Interface
Java applet
Java applet  what are types of applets
disable keyboard in java applet
disable keyboard in java applet  How to disable key board of my client in an java applet embedded in a website while the applet is running.? Plz help
Java applet
Java applet  How do you set security in applets
Java applet
Java applet   How are the differences between Applets and Applications
Java applet
Java applet  What is the sequence for calling the methods by AWT for applets
Java applet
Java applet  What is the relationship between the Canvas class and the Graphics class
Java applet
Java applet  What is the relationship between the Canvas class and the Graphics class
java - Applet
java  what is the use of java.utl  Hi Friend, The java...://www.roseindia.net/java/example/java/util/ http://www.roseindia.net/java/example/java/util/java-util-package.shtml Thanks
Java applet
Java applet  How can I arrange for different applets on a web page to communicate with each other
java - Applet
://www.roseindia.net/java/example/java/swing/graphics2D/index.shtml Thanks
Java applet
Java applet  I wanted as many clicks are there ,circles should be displayed there. I tried this code but it erases previous circles. plz help. public void mouseClicked(MouseEvent m) { x=m.getX(); y=m.getY
Java applet
Java applet  I wanted as many clicks are there ,circles should be displayed there. I tried this code but it erases previous circles. plz help. public void mouseClicked(MouseEvent m) { x=m.getX(); y=m.getY
Java Applet
Java Applet  Hi, I have a query, on every mouse click an oval should be drawn. But in my program I have used repaint() function, therefore previous oval gets erased.How to avoid this so that I get more than one oval. PFB
Java Applet
Java Applet  Hi, I have a query, on every mouse click an oval should be drawn. But in my program I have used repaint() function, therefore previous oval gets erased.How to avoid this so that I get more than one oval. PFB

Ads