G
geletine
I am a bigginner java programmer, thats obvious from the post, anyway i
am trying out this experiment, the program asks the users name, there
sex and there age.
the name is nothing more than a name, there sex determines weather they
can get a senior travel discount at 60 for females and 65 for males,
the standard discount can also be given to anyone 16 or under, anyone
older than 16 and younger than 60 cannot get a discount, anyone older
than 150 is considered dead.
I think i should be using two diffrent if statements, instead i have
combinded them together.
I start of by asking what there name is then there sex, if they are
male it asks there age and should decided weather there are 65 and
older to give them a senior bus card or under 65 but older than 16 to
give them no discount, if there 16 and younger a travelcard discount
and if they are over 150 there should be dead.
If they are not male then it asks if they are 60 or over, if they are
they get a senior travelcard if there 16 and younger a travelcard , if
they older than 16 but younger than 60 no travelcard and lastly if
there over 150 they should be dead.
here is my first attempt, :
import java.io.*;
public class bus
{
public static void main (String args [])throws IOException
{
String name, input, male;
int age;
BufferedReader info = new BufferedReader ( new InputStreamReader (
System.in ) );
System.out.println ("Enter your name");
input = info.readLine();
name = input;
System.out.println ("Are you male? ");
input = info.readLine();
male = input;
System.out.println ("Enter your age");
input = info.readLine();
age = Integer.parseInt ( input );
if ((male) || (age >= 65))
{
System.out.println ( name + " is entitled to a senior travelcard
");
}
else if ((male) || (age < 65))
{
System.out.println ( name + " is not entitled to a senior
travelcard ");
}
else if ((male) || ( age >= 150))
{
System.out.println ( name + " , you are kidding, what are you on?
");
}
else if (age >= 150)
{
System.out.println ( name + " , you are kidding, what are
you on ? ");
}
else if (age <= 16)
{
System.out.println ( name + " is entitled to a bus pass");
}
else if (age >= 60)
{
System.out.println (name + " is entitled to a senior bus
pass ");
}
else
{
System.out.println ( name + " is not allowed a bus pass");
}
}
}
am trying out this experiment, the program asks the users name, there
sex and there age.
the name is nothing more than a name, there sex determines weather they
can get a senior travel discount at 60 for females and 65 for males,
the standard discount can also be given to anyone 16 or under, anyone
older than 16 and younger than 60 cannot get a discount, anyone older
than 150 is considered dead.
I think i should be using two diffrent if statements, instead i have
combinded them together.
I start of by asking what there name is then there sex, if they are
male it asks there age and should decided weather there are 65 and
older to give them a senior bus card or under 65 but older than 16 to
give them no discount, if there 16 and younger a travelcard discount
and if they are over 150 there should be dead.
If they are not male then it asks if they are 60 or over, if they are
they get a senior travelcard if there 16 and younger a travelcard , if
they older than 16 but younger than 60 no travelcard and lastly if
there over 150 they should be dead.
here is my first attempt, :
import java.io.*;
public class bus
{
public static void main (String args [])throws IOException
{
String name, input, male;
int age;
BufferedReader info = new BufferedReader ( new InputStreamReader (
System.in ) );
System.out.println ("Enter your name");
input = info.readLine();
name = input;
System.out.println ("Are you male? ");
input = info.readLine();
male = input;
System.out.println ("Enter your age");
input = info.readLine();
age = Integer.parseInt ( input );
if ((male) || (age >= 65))
{
System.out.println ( name + " is entitled to a senior travelcard
");
}
else if ((male) || (age < 65))
{
System.out.println ( name + " is not entitled to a senior
travelcard ");
}
else if ((male) || ( age >= 150))
{
System.out.println ( name + " , you are kidding, what are you on?
");
}
else if (age >= 150)
{
System.out.println ( name + " , you are kidding, what are
you on ? ");
}
else if (age <= 16)
{
System.out.println ( name + " is entitled to a bus pass");
}
else if (age >= 60)
{
System.out.println (name + " is entitled to a senior bus
pass ");
}
else
{
System.out.println ( name + " is not allowed a bus pass");
}
}
}