Help with NetBeansHELP!!!
41 Replies - 1510 Views - Last Post: 17 February 2009 - 04:05 AM
#1
Help with NetBeans
Posted 16 February 2009 - 11:47 PM
Replies To: Help with NetBeans
#2
Re: Help with NetBeans
Posted 16 February 2009 - 11:56 PM
#3
Re: Help with NetBeans
Posted 17 February 2009 - 12:00 AM
#4
Re: Help with NetBeans
Posted 17 February 2009 - 12:52 AM
Package A: 9.95 a month with 10 hrs of service, additional hrs 2.00 per hour
Package B: 13.95 a month with 20 hrs of service, additional hrs 1.00 per hour
Package C: 19.95 a month with unlimited access
I think I know how to make the questions appear but what I dont know how to do is to input these numeric values and input it so that when the person picks the package and the amount of hours used it does the calculations. I know this is annoying but if ANYONE can help I'd appreciate it so much.
#5
Re: Help with NetBeans
Posted 17 February 2009 - 01:16 AM
#6
Re: Help with NetBeans
Posted 17 February 2009 - 01:21 AM
//take the input from the user in a variable(for example variable Input)
switch(Input){
case: A
//package a was chosen, take input(number of hours) and do the calculation
break;
case: B
//package b was chosen... do as above
break;
case C:
//same as above
break;
default:
//wrong input...
break;
}
hope this helps, if you could show us some code it would be much better thanks
This post has been edited by ayman_mastermind: 17 February 2009 - 01:22 AM
#7
Re: Help with NetBeans
Posted 17 February 2009 - 01:27 AM
#8
Re: Help with NetBeans
Posted 17 February 2009 - 01:30 AM
This post has been edited by ayman_mastermind: 17 February 2009 - 01:32 AM
#9
Re: Help with NetBeans
Posted 17 February 2009 - 01:37 AM
public class InternetServiceProvider {
public static void main(String[] args)
{
double input; //package picked by user
double hours; //hours used by user
double addhrs; //additional hours used by user
the thing is that i pretty much have no clue on how to use this program so i'm winging it
Do i have to first categorize the different variables? and if i do how do i make the coding for combining the answers when it comes to picking a specific package?
#10
Re: Help with NetBeans
Posted 17 February 2009 - 01:39 AM
addhrs = hours - 20 //this is in case the user chooses package B that has a 20 hours...
as for you input and hours variable it should get the input from the user.., which method does your professor told you to use? Scanner, Buffered Reader, JOptionPane...? btw, your input variable should be either of type string or char because the user will input letters and not decimal numbers, here is the initialization: String input; or you can do char input;
This post has been edited by ayman_mastermind: 17 February 2009 - 01:41 AM
#11
Re: Help with NetBeans
Posted 17 February 2009 - 01:40 AM
import java.util.Scanner;
public class InternetServiceProvider {
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);//creates a new scanner object
char input = sc.nextLine().charAt(0); //lets user input a character
double hours = sc.nextDouble(); //inputs double
double addhrs = sc.nextDouble();//inputs double
switch(input)//switch to do the calculations depending on the package
{
case 'A':
case 'B':
case 'C':
}
hope this helps
#12
Re: Help with NetBeans
Posted 17 February 2009 - 01:42 AM
#13
Re: Help with NetBeans
Posted 17 February 2009 - 01:44 AM
#14
Re: Help with NetBeans
Posted 17 February 2009 - 01:45 AM
input = JOptionPane.showInputDialog(null,"Enter your input");
and the input is taken and stored in the variable input...
or if you wan to get your input variable as char, then asign another variable for input such as UserInput as string,
String UserInput; UserInput = JoptionPane.showInputDialog(null,"Enter your input");
then convert(parse) the string to char to a variable that is input...
This post has been edited by ayman_mastermind: 17 February 2009 - 01:52 AM
#15
Re: Help with NetBeans
Posted 17 February 2009 - 01:56 AM
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);//creates a new scanner object
char input = sc.nextLine().charAt(0); //lets user input a character
double hours = sc.nextDouble(); //inputs double
double addhrs = sc.nextDouble();//inputs double
switch (input)//switch to do the calculations depending on the package
{
case 'A':
case 'B':
case 'C':
input = JOptionPane.showInputDialog(null, "Enter your input");
Alright so where do i put the values of the packages and the additional hours if they are any? for example for package A it's 9.95 a month and 10 hours of service are provided, if it's over 10 hours it'll charge 2.00 per additional hour, how and where do i write this down?
|
|

New Topic/Question
Reply




MultiQuote





|