Computer Science Canada if statements and a bit of color assistance |
Author: | rto [ 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 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 |
Author: | Reality Check [ 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:
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. |