Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 if statements and a bit of color assistance
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
rto




PostPosted: Wed Jun 04, 2008 11:13 am   Post subject: if statements and a bit of color assistance

alright guys , i need a bit of help here. im doing an ISP for computer science, culminating actiity, whatever it is u call it where you are, and i am making a video rental thinger. dont ask it was assigned to me Smile ok so heres my code and i'll let ya know what i need help with after

// The "ISP" class.
import java.awt.*;
import hsa.Console;
public class ISP
{

static Console c;
public static void main (String[] args)
{

c = new Console ();
String status;
String password;
String reply;
c.print ("Welcome to Ryan's videos! Are you a customer or an admin?");
status = c.readString ();
//For admins
c.print (Please enter a password ");
password = c.readString

}// main method

}// ISP class

so basically i need to make an if statement. for example for turing it would be like this:
if password = "password" then
put "Correct"
else if password not = "password" then
put "access denied"
. .. .. how do i do this in java?
second, i want the password to be whited out or starred or whatever. so instead of seeing what the user is typing, anybody else reading the output will see ******** instead of password (or just blank spaces or whatever) if you can help me thanks Very Happy
Sponsor
Sponsor
Sponsor
sponsor
Reality Check




PostPosted: Wed Jun 04, 2008 2:07 pm   Post subject: Re: if statements and a bit of color assistance

So your teacher HASN'T taught you this? If structures are pretty elementary. Here is a BRIEF example:

code:

int num = 2;
if (num == 2)
{
     System.out.println ("Your number is two");
}


Your argument check is made in the brackets and let the squigly act as your "then". To close the if statement just use a closing squigly. There are of course other forms of selection structures such as while loops and I would highly recommend reading wtd's intro to java. You obviously have not been taught anything about methods or objects yet. You may not understand it all but I think understanding it the right way first is the best way. He covers all the basics of java and understanding his intro (or at least most of it if you can't understand all) will make you better. I still regret that I wasted a whole year in grade 11 programming using the Console.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: