Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 136,248 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 2,217 people online right now. Registration is fast and FREE... Join Now!




random and continue

 
Reply to this topicStart new topic

random and continue, How would this look in C#

jsewall
13 Oct, 2008 - 10:23 AM
Post #1

New D.I.C Head
*

Joined: 13 Oct, 2008
Posts: 1

//1. Declare a integer myRandom
int myRandom;
myRandom = myRandom;
2. Declare a second integer named yourGuess.
int guess;
guess = uess
3. Use the iw.GetInt() to prompt the user for a guess something like:
Guess:
4. Save the user’s guess in the variable yourGuess.
5. If yourGuess is equal to myRandom, display “RIGHT!” on the console. Otherwise (else) display “sorry…”.
6. Add a loop to your program so that you prompt the user to guess until he guesses correctly. (Do not change the value of myRandom in the loop.)
7. Add a counter to the loop. After he guesses correctly, tell him how many guesses he made. You can do this by declaring an int variable before you start the loop. Set its initial value to zero. Then in the loop, increment it with the ++ operator. After you exit the loop its value will be the number of iterations of the loop you have completed.
8. Add a conditional to your loop right after the prompt for userGuess that will cause the loop to restart if the user enters a value less than zero or greater than 9. You can use the continue command
//11. Declare a double named rate.
12. Write a switch statement which will condition on the entered value (user) to assign a value to rate according to this schedule:
Overnight 12.00
Second Day 4.50
Express 2.50
Parcel Post 2.25
Unrecognized 0.00
Where Unrecognized is the default if no other case matches.
13. Display the resulting rate on the console as:
“The shipping charge will be ______.”

This post has been edited by jsewall: 13 Oct, 2008 - 11:24 AM
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Random And Continue
13 Oct, 2008 - 10:47 AM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,983



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.
User is offlineProfile CardPM
+Quote Post

gbertoli3
RE: Random And Continue
13 Oct, 2008 - 03:26 PM
Post #3

DIC at Heart + Code
Group Icon

Joined: 23 Jun, 2008
Posts: 1,046



Thanked: 17 times
Dream Kudos: 950
My Contributions
What exactly is your question?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 03:59AM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month