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

Username:   Password: 
 RegisterRegister   
 Quiz program -- restarting
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
kungfu




PostPosted: Sat Jan 20, 2007 3:18 pm   Post subject: RE:Frequently Asked Questions (And Answers!)

I need help repeating my "quiz" program. I just started learning so plz don't kill me. I'm also sorry i don't know how to upload stuff... so here. The problem is I want the program to restart after the user inputs either Y (yes) or N (no). Yes means they restart, No means they quit, and if it is anything else they are asked if they want to restart, with the yes or no choices. It stops if th user inputs "Y" or "N", and i don't know how to get it...




setscreen ("graphics.vga")
var x:=+4
var yn : string
var font := Font.New ("Lucida Fax:7:bold")
var winfont :=Font.New ("Lucida Fax:10:bold")
var wrongfont:=Font.New ("Lucida Fax:8:bold")
var command : string
var score : int := 0
var permark:real

proc drawq (question, a, b, c, d, right, wrong, winpic, wrongpic : string)

colorback (121)
cls
var bkg := Pic.FileNew ("USWW.bmp")

%Create Procedure
%===============================================================================================
loop

put "Press e to exit."
put "" %for spacing between lines
Pic.Draw (bkg, 100, 55, picCopy)
Font.Draw (question, 101, maxy - 65, font, 4)
Font.Draw ("a." + a, 101, maxy - 100, font, 4)
Font.Draw ("b." + b, 101, maxy - 125, font, 4)
Font.Draw ("c." + c, 101, maxy - 150, font, 4)
Font.Draw ("d." + d, 101, maxy - 175, font, 4)
locate (20, 1)
get command

if command = right then
score += 1
cls
Font.Draw ("Congratulations! You sure know your history!", 195 ,50, winfont, 1)
Font.Draw ("Please press any key to continue...", 227, 25, winfont, 1)
Pic.ScreenLoad (winpic, 120, 75, picCopy)
Input.Pause
cls
exit
else
case command of
label "a", "b", "c", "d" :
Pic.ScreenLoad (wrongpic, 1, 1, picCopy)
Draw.FillBox (30, 140, 600, maxy - 210, 121)
Font.Draw (wrong, 50, maxy - 225, wrongfont, 0)
Font.Draw ("Please press any key to continue...", 130, maxy - 250, wrongfont, 0)
Input.Pause
exit
label "e" :
exit
label :
put "-_-' Please enter a valid choice..." %If the user types anthing else.
end case %program will quit...if a real number typed
end if
cls
end loop
cls
end drawq

%Questions
%===================================================================================================
%Question 1
drawq ("When did the 'official' war start?",
"1923, September 30",
"1816, December 10",
"1910, April 1 ",
"1939, September 3",
"d",
"Your answer was incorrect...1939, September 3 was the answer.",
"win.jpg", "ww2-66.jpg")


%Question 2
drawq ("Who initiated the war?",
"'Nazi' Germany",
"Poland",
"United States",
"Japan",
"a",
"Your answer was incorrect...Nazi Germany was the answer.",
"win.jpg", "ww2-66.jpg")


%Question 3
drawq ("What did they do to initiate the war?",
"Offend the Queen of England",
"Assassinate JFK",
"Invade Poland",
"Attatck Pearl Harbour",
"c",
"Your answer was incorrect...Nazi Germany invaded Poland to initiate the war.",
"win.jpg", "ww2-66.jpg")


%Question 4
drawq ("What were the Nazi bombing runs on London called?",
"The Bombs",
"Operation:Blitzkreiger",
"Pearl Harbour",
"The Blitz",
"d",
"Your answer was incorrect...The bombing runs on London were called 'The Blitz'.",
"win.jpg", "ww2-66.jpg")


%Question 5
drawq ("How did the country of China become part of the axis forces?",
"Agreed to join formally",
"They were captured by Japan",
"Germany liked their cooking",
"The Nazis threatened them with force",
"b",
"Your answer was incorrect...China was captured by Japan and joined under the Japanese.",
"win.jpg", "ww2-66.jpg")


%Question 6
drawq ("What was the American Navy port in Hawaii called?",
"Pearl Harbour",
"Pearl Port",
"Pearl Harbor",
"Hawaii Harbor",
"c",
"Your answer was incorrect...the American port is called Pearl Harbor .",
"win.jpg", "ww2-66.jpg")


%Question 7
drawq ("Who was the victor of the 'Battle of Midway'?",
"United States",
"Japanese",
"Nazis",
"England",
"a",
"Your answer was incorrect...the United States were the victors of the 'Battle of Midway'.",
"win.jpg", "ww2-66.jpg")


%Question 8
drawq ("What was the name of the beach invovled in D-Day?",
"Hamoa Beach",
"Wasaga Beach",
"Anguilla Beach",
"Beaches of Normandy",
"d",
"Your answer was incorrect...the involved in D-Day were the Beaches of Normandy.",
"win.jpg", "ww2-66.jpg")


%Question 9
drawq ("Approx. how many allied casualties were there in the Battle of the Bulge?",
"100 000",
"90 000",
"50 000",
"10 000",
"b",
"Your answer was incorrect...there were approximately 90 000 allied causalties.",
"win.jpg", "ww2-66.jpg")


%Question 10
drawq ("At what date the the Nazis officially surrender?",
"March 12, 1946",
"January 10, 1944",
"May 8, 1945",
"April 9, 1936",
"c",
"Your answer was incorrect...the Nazis officially surrendered on May 8, 1945.",
"win.jpg", "ww2-66.jpg")


%Question 11
drawq ("What were the two Japanese cities that had atomic bombs dropped on them?",
"Tokyo & Hiroshima",
"Hiroshima & Nagasaki",
"Nagasaki& Yokohama",
"Osaka & Hiroshima",
"b",
"Your answer was incorrect...the bombs were dropped on Hiroshima & Nagasaki.",
"win.jpg", "ww2-66.jpg")


%Question 12
drawq ("How many days after the second atomic bomb did the Japanese surrender?",
"6",
"4",
"2",
"1",
"a",
"Your answer was incorrect...the Japanese surrendered 6 days after the Nagasaki bombing.",
"win.jpg", "ww2-66.jpg")







%Marking
%===================================================================================================
put score,"/12"
permark:=(score/12)*100

put permark,"%"

if score>=10 then
Pic.ScreenLoad ("moh.jpg", x+260, x+100, picCopy)
elsif score=9 then
Pic.ScreenLoad ("9.jpg", x+275, x+100, picCopy)
elsif score=8 then
Pic.ScreenLoad ("8.jpg", x+272, x+100, picCopy)
elsif score=7 then
Pic.ScreenLoad ("7.jpg", x+275, x+100, picCopy)
elsif score<=6 then
put "Good try, but if you get 7 or higher next time, you will be rewarded!"
end if

%Restart
%===================================================================================================

put "Retry quiz? Y= yes / N= no"

loop
get yn
if yn = "Y" then
return
elsif yn= "N" then
exit
else
put "Retry quiz? Y= yes / N= no"
end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
agnivohneb




PostPosted: Sun Jan 21, 2007 1:18 pm   Post subject: Re: Quiz program -- restarting

I would like to help but i get a picture error.
put everything in a zip folder. then at the bottom of the post page (were you type in your problem). there is a button that says add an attachment click that and upload you zip file then i can help you.
neufelni




PostPosted: Sun Jan 21, 2007 1:44 pm   Post subject: RE:Quiz program -- restarting

All that you need to do is put your questions into a loop. Then at the end of you questions, ask if they want to restart. If they don't enter Y then exit the loop.
Turing:
%Questions
loop
    %=========================================================
    drawq ("When did the 'official' war start?",
        "1923, September 30",
        "1816, December 10",
        "1910, April 1 ",
        "1939, September 3",
        "d",
        "Your answer was incorrect...1939, September 3 was the answer.",
        "win.jpg", "ww2-66.jpg")
       
        ... All other questions here


    %Marking
    %======================================================
    put score, "/12"
    permark := (score / 12) * 100

    put permark, "%"

    if score >= 10 then
        Pic.ScreenLoad ("moh.jpg", x + 260, x + 100, picCopy)
    elsif score = 9 then
        Pic.ScreenLoad ("9.jpg", x + 275, x + 100, picCopy)
    elsif score = 8 then
        Pic.ScreenLoad ("8.jpg", x + 272, x + 100, picCopy)
    elsif score = 7 then
        Pic.ScreenLoad ("7.jpg", x + 275, x + 100, picCopy)
    elsif score <= 6 then
        put "Good try, but if you get 7 or higher next time, you will be rewarded!"
    end if

    %Restart
    %===============================================

    put "Retry quiz? Y= yes"
    get yn
    exit when yn not= "Y" and yn not= "y"
end loop
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  [ 3 Posts ]
Jump to:   


Style:  
Search: