Results 1 to 4 of 4
  1. #1
    syntrax is offline Member
    Join Date
    Sep 2009
    Location
    http://www.kouje.com
    Posts
    16
    Rep Power
    0

    Default How to split a file into 2?

    this is for a school project, and this program is suppose to be in 2 files, using the "set" and "get" things,,, but I still haven't really understood them. I coded my program in a single file and i need help on how to split it into 2,, the code works just fine. and the "CurrentDateTime" class is working just fine. here's the code:

    Java Code:
       import java.text.*;
       import java.util.Scanner;
       import java.text.DecimalFormat;
    /**
     * @author ;)
     * @version 4.00 2009/9/22
     */
         public class Assignment04 
       {
           public static  void main(String args[])
          {
             String input; //to hold user's input
             char pk_type; 
             Double pk_price;
             Double internetHours;
             Double payPrice;
          
          // Get current date
             CurrentDateTime today = new CurrentDateTime();
          
          // read input
             Scanner keyboard = new Scanner(System.in);
          
          // decimal format object
             DecimalFormat formatter = new DecimalFormat("#,##0.00");
          
          // Print Date
             System.out.println("''''''''''''''''''''''''''''''''''");
             System.out.println(today.getDateTime());
             System.out.println("''''''''''''''''''''''''''''''''''\n");
          
          // get internet package type
             System.out.print("Enter your Internet package type: ");
             input = keyboard.nextLine();
          	
             System.out.print("For how many hours did you surf the web? ");
             internetHours = keyboard.nextDouble();
          
             pk_type = input.charAt(0);
          
          /**
          *********************************************************************************************
          ************************************* CUT HERE? **********************************************
          *********************************************************************************************
          */
          
          // determine the package type
             switch(pk_type)
             {
                case 'a':
                case 'A':
                   if(internetHours > 10)
                   {
                      payPrice = internetHours + 2;
                      System.out.println("****** You went over your monthly limit of 10 hours. "
                         			+ "This month's bill is $" + formatter.format(payPrice) + " ******");
                   }
                   else
                   {
                      System.out.println("Package A this month's bill is: $9.95");
                   }
                   break;
             	
                case 'b':
                case 'B':
                   if(internetHours > 20)
                   {
                      payPrice = internetHours + 1;
                      System.out.println("You went over your monthly limit of 20 hours. "
                         			+ "This month's bill is $" + formatter.format(payPrice));
                   }
                   else
                   {
                      System.out.println("Package B this month's bill is: $14.95");
                   }
                   break; 
             		   			
                case 'c':
                case 'C':
                   System.out.println("Package C has Unlimited internet acces. This month's bill is: $19.95");
                   break;
                default:
                   System.out.println("Invalid internet package. Please choose between package A, package B, or package C. SINGLE LETTERS ONLY");
             }
          }
       }
    Last edited by Fubarable; 09-26-2009 at 03:10 AM. Reason: Code tags added to aid in code readability

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

  3. #3
    syntrax is offline Member
    Join Date
    Sep 2009
    Location
    http://www.kouje.com
    Posts
    16
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    Code tags were added to the code in the original post to aid in readability.
    -- mod
    thank you ^.^

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

Similar Threads

  1. How to split a String using split function
    By Java Tip in forum java.lang
    Replies: 4
    Last Post: 04-17-2009, 09:27 PM
  2. split() by digits
    By RobertF in forum New To Java
    Replies: 2
    Last Post: 03-12-2009, 03:16 AM
  3. split Keyword
    By santhoshrao in forum New To Java
    Replies: 4
    Last Post: 08-13-2008, 11:28 AM
  4. how to split a file
    By nagaraaju in forum New To Java
    Replies: 0
    Last Post: 03-14-2008, 09:45 AM
  5. How to split a String using split function
    By JavaBean in forum Java Tip
    Replies: 0
    Last Post: 10-04-2007, 10:32 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
  •