HELP working with 2 classes!!! URGENT!
ok, I need help connecting these 2 files, this code used to be in all in the same class, but my instructor won't accept it like that.
I've always had problems moving anything between classes and files and now I'm stuck trying to select the package type.
This program is for an ISP. It includes 3 pakcages, A, B, and C. each one has their own pricing and internet access. The program should ask the user to input their package type and hours of use. But I cannot send data to a class,, how to do it? ty in advanace,, here's my code:
Code:
import java.text.DecimalFormat;
import java.text.*;
public class ISP
{
String input; //to hold user's input
char pk_type;
Double pk_price;
Double internetHours;
Double payPrice;
private Double calculate;
public void setCalculate(String fgh)
{
// decimal format object
DecimalFormat formatter = new DecimalFormat("#,##0.00");
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");
}
}
public double getCalculate()
{
return calculate;
}
}
================================================== ========
Code:
import java.text.*;
import java.util.Scanner;
import java.text.DecimalFormat;
public class Assignment04
{
public static void main(String args[])
{
ISP ispPk = new ISP();
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();
}
}