Click here to Skip to main content
16,012,843 members
Home / Discussions / C#
   

C#

 
GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan14-May-13 21:24
mveRichard MacCutchan14-May-13 21:24 
GeneralRe: Method Not Returning a Value Pin
N8tiv15-May-13 20:29
N8tiv15-May-13 20:29 
GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan15-May-13 21:46
mveRichard MacCutchan15-May-13 21:46 
GeneralRe: Method Not Returning a Value Pin
N8tiv15-May-13 23:10
N8tiv15-May-13 23:10 
GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan16-May-13 1:17
mveRichard MacCutchan16-May-13 1:17 
GeneralRe: Method Not Returning a Value Pin
N8tiv16-May-13 4:27
N8tiv16-May-13 4:27 
GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan16-May-13 5:02
mveRichard MacCutchan16-May-13 5:02 
GeneralRe: Method Not Returning a Value Pin
N8tiv16-May-13 6:13
N8tiv16-May-13 6:13 
Yeah, I was just playing around with the different data types to see what kind of output I would get…
I guess I forgot to change it back to an int datatype before posted…

I tried playing around with the do while loop… I'm going to have to study that much more before I try to implement it in anything.

However, my if statements are acting a little funny…
I couldn't get the regular do while loop to work quite right either, I'll try to play around with a little bit later…

When I answered yes to both numbers, it does fine and does the calculation…Thumbs Up | :thumbsup:

I entered the first number and then answer no, it starts over like it's supposed to…Thumbs Up | :thumbsup:

Then I go to enter the first number again, this time I answered yes…
it moves like it's supposed to…Thumbs Up | :thumbsup:

I go to enter the second number and answer no, it starts the second number over like it's supposed to…Thumbs Up | :thumbsup:
then I answered the second number again, this time answering yes… For some reason it looks like the first digit is cut offConfused | :confused: Confused | :confused:

For both numbers I used the number 5, in this particular scenario… When it's working, the answer should be 3125…
only 125 shows up when I answer no for the second question, the first time…

enter number 5
y
enter number 2
n
enter second number again 5
calculates and shows 125
C#
using System;

namespace CalculatetothePowerof
{
    class Program
    {
        static void Main()
        {
            int valOne = AcceptValue("Enter your first number:");
            int valTwo = AcceptValue("\nEnter your second number:");
            Console.WriteLine(Math.Pow(valOne, valTwo));
            Console.Read();
        }
        static int AcceptValue(string message)
        {
            Console.WriteLine(message);
            string valueOne = Console.ReadLine();
            int IntOne = Convert.ToInt32(valueOne);
            Console.WriteLine("Are you sure you want to use that number?\nPress lowercase y or n, to continue.");
            string YesNo = Console.ReadLine();
            if (YesNo == "y")
                return IntOne;
            else
            {
                Console.Clear();
                AcceptValue(message);
            }
            return IntOne;
        }
    }
}


GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan16-May-13 6:46
mveRichard MacCutchan16-May-13 6:46 
GeneralRe: Method Not Returning a Value Pin
N8tiv16-May-13 7:42
N8tiv16-May-13 7:42 
GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan16-May-13 20:40
mveRichard MacCutchan16-May-13 20:40 
GeneralRe: Method Not Returning a Value Pin
N8tiv17-May-13 11:31
N8tiv17-May-13 11:31 
GeneralRe: Method Not Returning a Value Pin
Richard MacCutchan17-May-13 22:50
mveRichard MacCutchan17-May-13 22:50 
GeneralRe: Method Not Returning a Value Pin
Pete O'Hanlon14-May-13 23:07
mvePete O'Hanlon14-May-13 23:07 
GeneralRe: Method Not Returning a Value Pin
N8tiv15-May-13 20:37
N8tiv15-May-13 20:37 
GeneralRe: Method Not Returning a Value Pin
Pete O'Hanlon15-May-13 23:50
mvePete O'Hanlon15-May-13 23:50 
GeneralRe: Method Not Returning a Value Pin
N8tiv16-May-13 0:29
N8tiv16-May-13 0:29 
GeneralRe: Method Not Returning a Value Pin
Pete O'Hanlon16-May-13 0:36
mvePete O'Hanlon16-May-13 0:36 
QuestionCreating Images on Different Layers Pin
ASPnoob14-May-13 11:40
ASPnoob14-May-13 11:40 
AnswerRe: Creating Images on Different Layers Pin
Ravi Bhavnani14-May-13 11:48
professionalRavi Bhavnani14-May-13 11:48 
AnswerRe: Creating Images on Different Layers Pin
SledgeHammer0114-May-13 12:51
SledgeHammer0114-May-13 12:51 
QuestionC# how save form in pdf/ and about calendar Pin
ghost22th14-May-13 4:39
ghost22th14-May-13 4:39 
AnswerRe: C# how save form in pdf/ and about calendar Pin
Richard MacCutchan14-May-13 5:11
mveRichard MacCutchan14-May-13 5:11 
QuestionSENDING MAIL DID NOT USING GMAIL DOMAIN Pin
mohamed kalif raja14-May-13 0:54
mohamed kalif raja14-May-13 0:54 
AnswerRe: SENDING MAIL DID NOT USING GMAIL DOMAIN Pin
Pete O'Hanlon14-May-13 2:10
mvePete O'Hanlon14-May-13 2:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.