Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Display the first and last digit of the value that the user entered.Use text to

ID: 3784380 • Letter: D

Question

Display the first and last digit of the value that the user entered.Use text to label them nicely. C#

Console.WriteLine("Give me a number in inches please so i can use some witchcraft to figure out the yardage,feet, and inches!");


int totalInches = Convert.ToInt32(Console.ReadLine());
int yards = totalInches / 36;
int remainingInches = totalInches % 36;
int feet = totalInches / 12;
int inches = totalInches % 12;

Console.WriteLine(yards + " yards, ");
Console.WriteLine(feet + " feet,");
Console.WriteLine(inches + " inches");

  

  
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
}

Explanation / Answer

Create new project click File > New Project in Visual C#.

Select text box from properties and put it in a form and name it as tinchesTextBox.
Select Button from properties and name it as Display and put it in form.
Click on button Display.

private void btndisplay _Click(object sender,EventArgs e)
{
int totalinches;
int yards;
int feet;
int inches;

int tincesTextBox;

int totalInches = Convert.ToInt32(tinchesTextBox.Text);
if(totalinches==0)
   MessageBox.Show("Enter value greater than Zero");

    if(totalinches<0)
    MessageBox.Show("Enter positive number");

else{
            int yards = totalInches / 36;
            int remainingInches = totalInches % 36;
            int feet = totalInches / 12;
            int inches = totalInches % 12;
}

MessageBox.Show (yards.ToString());
MessageBox.Show(feet.ToString());
MessageBox.Show(inches.ToString());
}