Results 1 to 9 of 9
  1. #1
    jen-eric is offline Member
    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Default please, help me with this code. please.

    :confused:

    i have these set of codes..
    how can i make this an applet?
    please help me.
    its a java class.


    Java Code:
    import java.awt.*;
    import java.util.Scanner;
    import java.util.Formatter;
    
    public class oye extends java.applet.Applet {
    
    	 public static void main (String[] args)
    	 
    	 {
    	 	int startTimeA;
    	 	int startTimeB;
    	 	int endTimeA;
    	 	int endTimeB;
    	 	double amount = 0.0;
    	 	int minutesDuration = 0;
    	 	int hoursDuration = 0;
    	 	int minutesConsumed = 0;
    	 	
    		Formatter f = new Formatter();
    	 	Scanner scan = new Scanner(System.in);
    	 	
    	 	System.out.print ("Log-in Time : " + "\n");
    	 	startTimeA = scan.nextInt();
    	 	startTimeB = scan.nextInt();
    	 	
    	 	System.out.print ("\n");	 	
    	 	System.out.print ("Log-out Time : "  + "\n");
    	 	endTimeA = scan.nextInt();
    	 	endTimeB = scan.nextInt();
    	 	
    	 	System.out.print ("\n");
    	 	
    	 	if ((startTimeA < 12) || (endTimeA < 12))
    	 	{
    	 		minutesDuration = endTimeB - startTimeB;
    	 	}
    	 	else
    	 	{
    	 		System.out.print ("Wrong Entry!" + "\n");
    	 		return;
    	 	}	
    	 	
    	 	if ((startTimeB <= 60) || (endTimeB <= 60))
    	 	{
    	 		hoursDuration = 60 * (endTimeA - startTimeA);
    		}
    	 	else
    	 	{
    	 		System.out.print ("Wrong Entry!" + "\n");
    	 		return;
    	 	}
    	 		
    	 	minutesConsumed = minutesDuration + hoursDuration;
    	 	
    	 	amount = 0.16666667 * minutesConsumed;
    	 	
    	 	if (amount > 0)
    	 	{
    	 		amount = 0.16666667 * minutesConsumed;
    	 		f.format("Amount : %.2f", amount);
    	 		System.out.println(f);
    	 		f.close();
    	 	}
    	 	else
    	 		System.out.print ("Amount cannot be negative!" + "\n");
    	 	
    	 }	
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Please read the sun tutorial on how to make applets (JApplets would be best) before even considering doing this. It will explain a lot and clear many of your misconceptions.

    Edit: start here: Lesson: Applets (The Java™ Tutorials > Deployment)
    Last edited by Fubarable; 03-10-2009 at 11:12 PM.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Also, don't try to convert that code to applet code as there is no way on heaven or earth that this will work. Instead create your new applet code from scratch.

  4. #4
    jen-eric is offline Member
    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Default

    can't i make an applet with that kind of "output"?
    i need it.
    please help me.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    You can work on with most types of output with Applets. Please go through the link Fubarable send in his previous post.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by jen-eric View Post
    can't i make an applet with that kind of "output"?
    You can reuse the code that does the calculations, sure, but all the code that interacts with the user via a Scanner object, and via println statements are mostly unusable with applets.
    i need it.
    please help me.
    Then study it and try to create one. You've nothing to lose by trying. Best of luck.

  7. #7
    Xyle's Avatar
    Xyle is offline Member
    Join Date
    Feb 2009
    Location
    Nevada
    Posts
    34
    Rep Power
    0

    Default

    Just wanted to add, one of the most important things (for me anyways) is the java applet architecture and each method a basic applet requires. You can take the majority of the code and squish it, squeeze it and hammer it into one of the applets methods to get it to work.

    Java Code:
    import libraries...
    define applet class name{
         list variables
         init() //Initialize variables and settings
         start() //Used when restarting applet or after Init()
         paint() //Used to draw things to screen using 
         stop() //closes all resources
         destroy() //executes just before applet closes, called when shutting down applet
    }
    You can look up each method to get further understanding of what each does at Java.sun.com

    Hope this helps a little! :D
    Last edited by Xyle; 03-19-2009 at 02:50 AM.

  8. #8
    Mr Me is offline Member
    Join Date
    Mar 2009
    Posts
    3
    Rep Power
    0

    Default Please Help......

    I have an assigment to submit on sunday 29th of this month and I dont know how to do it cause I am new to java programming. Please someone me out with the java codes...
    this is my proposed proposal for the assignment.
    proposal.
    Application System: Airline Reservation System
    Subsystem Selected: Ticketing System

    Introduction:
    This is to propose on the development of a ticketing subsystem of an Airline ticketing system. The application subsystem chosen is the airline reservation system, the subsystem will include of some functionalities which are;
    Ticket reservation,
    Manage a Booking,
    Flight Schedule and
    Baggage allowance calculator.
    Ticket reservation is all about the customer(s) booking ticket(s) for flights. This will be done by following the necessary procedures for creating a system. The various aspects that will be touched during this development are the system selection stage, requirement specification, analysis models, design specifications and modeling, design pattern implementation, user interface design, the generation of code, and testing phase.


    Functionality:
    • Ticket reservation: here the customer when booking a ticket for flight, there are information provided such as the price for particular flight booked.
    • Manage a Booking: here customers are given opportunity to cancel or extend their bookings.
    • Flight schedules: this allows the customer to check flight schedules and its availability before making booking.
    • Baggage allowance calculator: allows the customer to the maximum weight of luggage allowed to be boarded on plane and it defers with distance.
    :confused:

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Why doesn't this code accept my code?
    By PeterFeng in forum New To Java
    Replies: 5
    Last Post: 02-03-2009, 02:39 PM
  2. I need help fixing my code.. or non code?
    By MrHuggykins in forum New To Java
    Replies: 1
    Last Post: 03-19-2008, 11:12 PM
  3. Replies: 1
    Last Post: 04-26-2007, 04:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •