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

Username:   Password: 
 RegisterRegister   
 How do I make a computer sleep using a program?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
storm2713687




PostPosted: Sat Mar 02, 2013 9:32 pm   Post subject: How do I make a computer sleep using a program?

Turing:

put "--------------------------------------------------------------------------------"
var y2 : real
procedure ytwo
    put "Enter the value of y2 here: " ..
    get y2
end ytwo
var y : real
procedure y1
    put "Enter the value of y(1) here: " ..
    get y
end y1
var x2 : real
procedure xtwo
    put "Enter the value of x2 here: " ..
    get x2
end xtwo
var x : real
procedure x1
    put "Enter the value of x(1) here: " ..
    get x
end x1
var continueorstop : string
loop %LOOP STARTS HERE
put "Welcome to Edward Yang's slope and y-intercept calculator. You can chose to havethe program to calculate just the slope or y-intercept, or both."
%Slope m=(y2-y1)/(x2-x1)
%Y-Int y=mx+b
var m : real
var b : real
put " "
put "Option 1: The program will calculate the slope only."
put "Option 2: The program will only calculate the y-intercept."
put "Option 3: The program will calculate both slope and y-intercept."
put " "
put "For Option 1, make sure you have the values of y2, y1, x2, and x1. The formula  that will be used to calculate the slope is m=(y2-y1)/(x2-x1)."
put "For Option 2, make sure you have the values of y, x, and m (slope)."
put "For Option 3, make sure y ou have the values of y2, y1, x2, x1, and the slope.  X1, and Y1 will be used to calculate the y-intercept."
put " "
var option : int
put "Enter which option you want to choose (1, 2, or 3): " ..
get option
put "--------------------------------------------------------------------------------"
if option = 1 then
    ytwo
    y1
    xtwo
    x1
    put " "
    put "m=y2-y1/x2-x1"
    put "m=", y2, "-", y, "/", x2, "-", x
    put "m=", y2 - y, "/", x2 - x
    m := (y2 - y) / (x2 - x) %Gives variable m a value
    put "m=", m
    put "The slope is ", m, "."   
    put "--------------------------------------------------------------------------------" 
elsif option = 2 then                                   
    x1
    y1
    put "Enter the slope here: " ..
    get m
    put " "
    put "y=mx+b"
    put y, "=", m, "*", x, "+b"
    put y, "=", m * x, "+b"
    put y, "-", m * x, "=b"
    b := y - (m * x)
    put b, "=b"
    put "The Y-Intercept is ", b, "."
    put "--------------------------------------------------------------------------------"
elsif option = 3 then
    ytwo
    y1
    xtwo
    x1
    put " "
    put "m=y2-y1/x2-x1"
    put "m=", y2, "-", y, "/", x2, "-", x
    put "m=", y2 - y, "/", x2 - x
    m := (y2 - y) / (x2 - x) %Gives variable m a value
    put "m=", m
    put "The slope is ", m, "."
    put " "
    put "y=mx+b"
    put y, "=", m, "*", x, "+b"
    put y, "=", m * x, "+b"
    put y, "-", m * x, "=b"
    b := y - (m * x)
    put b, "=b"
    put "The Y-Intercept is ", b, "."
    put "--------------------------------------------------------------------------------"
end if
put "Would you like the program to continue?"
put "Type and press enter yes if you would like to continue, no to stop the program."
get continueorstop
if continueorstop = "No" then
    exit
elsif continueorstop = "no" then   
    exit
elsif continueorstop = "Yes" then
elsif continueorstop = "yes" then
else
    put "Since you decided to troll the program, the program will now troll you."
    %I need the sleep code to be put here
    put "The program will now stop."
    exit
end if
end loop



That's the program I'm making, which I stated in the ending where I want it to be. Does anyone know what the code is to make the computer sleep? Smile
I'm just giving this to my friends, so I don't want to make them turn off, which I found tuts for that, but just not making the computer sleep.

Also, please help me simplify this if you want to Razz
Thanks Smile
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sat Mar 02, 2013 9:39 pm   Post subject: RE:How do I make a computer sleep using a program?

delay would make the program suspend for some time, but I suspect that's not quite what you are looking for.

Perhaps drawing pictures of cats will serve your trolling purposes better.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
storm2713687




PostPosted: Sat Mar 02, 2013 9:46 pm   Post subject: Re: RE:How do I make a computer sleep using a program?

Tony @ Sat Mar 02, 2013 9:39 pm wrote:
delay would make the program suspend for some time, but I suspect that's not quite what you are looking for.

Perhaps drawing pictures of cats will serve your trolling purposes better.


LOOOOOOOL. Sure, but I haven't gotten there in turing yet Razz
I'm using Cervantes' walkthrough, which I've only gotten to Loops Sad
Well, what does delay do? What does it delay?
Raknarg




PostPosted: Sat Mar 02, 2013 10:00 pm   Post subject: RE:How do I make a computer sleep using a program?

It pauses the program itself. If you call delay (10000) it will pause the program at that line for 10 seconds.

There are more troll worthy programs you can make with turing, but they can be quite mean so I'll let you find them on your own.
storm2713687




PostPosted: Sat Mar 02, 2013 10:04 pm   Post subject: Re: RE:How do I make a computer sleep using a program?

Raknarg @ Sat Mar 02, 2013 10:00 pm wrote:
It pauses the program itself. If you call delay (10000) it will pause the program at that line for 10 seconds.

There are more troll worthy programs you can make with turing, but they can be quite mean so I'll let you find them on your own.


Lol alright Razz
I don't think I will ever find any though, not unless there's a tut for it xD
Tony




PostPosted: Sat Mar 02, 2013 10:55 pm   Post subject: RE:How do I make a computer sleep using a program?

somebody has to figure things out for the first time to write those tutorials in the first place...

Computer Science is about building blocks. You learn some basics and build up more and more complicated stuff from that prior experience. Don't be afraid to try new things instead of only following the instructions Wink http://compsci.ca/blog/programming-is-like-lego/
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
storm2713687




PostPosted: Sun Mar 03, 2013 8:34 pm   Post subject: Re: RE:How do I make a computer sleep using a program?

Tony @ Sat Mar 02, 2013 10:55 pm wrote:
somebody has to figure things out for the first time to write those tutorials in the first place...

Computer Science is about building blocks. You learn some basics and build up more and more complicated stuff from that prior experience. Don't be afraid to try new things instead of only following the instructions Wink http://compsci.ca/blog/programming-is-like-lego/


Lol thanks Razz
For now, I'll just learn more from tuts then I'll go and play around Laughing


Edit: Hey Raknarg, how do you do the delay thing? It might come in handy Razz
Insectoid




PostPosted: Sun Mar 03, 2013 9:20 pm   Post subject: RE:How do I make a computer sleep using a program?

Literally just type delay (n) on a line, where n is the number of milliseconds to pause for. Remember, there's 1000 milliseconds in a second.
Sponsor
Sponsor
Sponsor
sponsor
storm2713687




PostPosted: Mon Mar 04, 2013 8:09 pm   Post subject: Re: RE:How do I make a computer sleep using a program?

Insectoid @ Sun Mar 03, 2013 9:20 pm wrote:
Literally just type delay (n) on a line, where n is the number of milliseconds to pause for. Remember, there's 1000 milliseconds in a second.


Oh okay thanks Razz
I've always thought there was 100 milliseconds in a second LOL.
Tony




PostPosted: Tue Mar 05, 2013 1:41 pm   Post subject: RE:How do I make a computer sleep using a program?

milli- is a prefix for 1/1000, the same way there are 1000 millimeters in a meter, and 1000 millilitres in a litre.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
storm2713687




PostPosted: Tue Mar 05, 2013 4:41 pm   Post subject: Re: RE:How do I make a computer sleep using a program?

Tony @ Tue Mar 05, 2013 1:41 pm wrote:
milli- is a prefix for 1/1000, the same way there are 1000 millimeters in a meter, and 1000 millilitres in a litre.

I've always thought it was 100 because I thought a millipede had 100 legs -_-
Stupid me, I forgot there were centipedes.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 11 Posts ]
Jump to:   


Style:  
Search: