Question

Using Visual Studio 2017 Create This Program Using C# implement source code Program 5: The concept...


Using Visual Studio 2017 Create This Program Using C#

implement source code

Program 5: The concept of a 5-digit palindrome number is a 5-digit number that reads the same from left to right and from right to left. For example, 12121, 45454, and 14741 are valid 5-digit palindrome numbers. Design (pseudocode) and implement (source code) a program (name it FiveDigitPalindrom) that reads a 5-digit number from the user (as integer value, not string) and then mathematically (using division and remainder operations) determines whether the entered number is a 5-digit palindrome or not. Assume valid inputs are from 11111 to 9999. The program rejects any input outside that range with the message “Invalid 5-digit number. Try again”. Document your code and properly label the input prompts and the outputs as shown below.

Sample run 1:

Entered number: 6754

Judgment:       Invalid 5-digit number. Try again

Sample run 2:

Entered number: 12321

Judgment:       Valid 5-digit palindrome

Sample run 3:

Entered number: 12324

Judgment:       Invalid 5-digit palindrome

0 0
Add a comment Improve this question Transcribed image text
Answer #1
using System;

public class FiveDigitPalindrom
{
    public static void Main(string[] args)
    {
        Console.Write("Enter a number: ");
        int number = Convert.ToInt32(Console.ReadLine());
        int temp = number, reversed = 0, count = 0;
        while (temp > 0)
        {
            reversed *= 10;
            reversed += temp % 10;
            temp /= 10;
            count++;
        }

        Console.WriteLine("Entered number: " + number);
        if (count == 5)
        {
            if (number == reversed)
            {
                Console.WriteLine("Judgment:       Valid 5-digit palindrome");
            }
            else
            {
                Console.WriteLine("Judgment:       Invalid 5-digit palindrome");
            }
        }
        else
        {
            Console.WriteLine("Judgment:       Invalid 5-digit number. Try again");
        }
    }
}

Add a comment
Know the answer?
Add Answer to:
Using Visual Studio 2017 Create This Program Using C# implement source code Program 5: The concept...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Design in Python (pseudocode) and implement (source code) a program (name it MyRectangle) that defines the...

    Design in Python (pseudocode) and implement (source code) a program (name it MyRectangle) that defines the following 3 methods: Method isValid() returns true if the sum of the width and height is greater than 30 Method Area() returns the area of the rectangle if it is a valid rectangle Method Perimeter() returns the perimeter of the rectangle if it is a valid rectangle The main method of MyRectangle prompts the user to enter the width and height of a rectangle...

  • C++ Design and implement a program (name it PalindromeInteger), to check if an integer value is...

    C++ Design and implement a program (name it PalindromeInteger), to check if an integer value is a palindrome or not, using 2 methods (reverse and isPalindrome) specified as follows: Method reverse(int number) takes integer number and returns number in reverse order. The method mathematically reverses the number. Method isPalindrome(int number) takes integer number and returns true if the number is palindrome; false otherwise. Use method reverse() to implement method isPalindrome(). Notice that an integer value is palindrome if the value...

  • Design and implement a Java program (name it PasswordTest) that accepts a string from the user...

    Design and implement a Java program (name it PasswordTest) that accepts a string from the user and evaluates it as a password, giving it a valid or invalid verdict A good password will be at least 8 characters and includes at least one lower-case letter, at least one upper-case letter, at least one digit, and at least one character that is neither a letter nor a digit. Your program will need to check each character in the string in order...

  • JAVA PROGRAM just do whats on the sample run.thanks Create a program that will accept positive...

    JAVA PROGRAM just do whats on the sample run.thanks Create a program that will accept positive N-digit (N is any possible number) number as an input. Then display if the number is a multiple of the following numbers: 11, 12, and 13. The program will also check for the validity of inputs. Sample run: MULTIPLE OF 7-11-13 >> Enter an N-Digit Number: 29531830000000 >> Multiple of 7 >> Multiple of 11 >> Multiple of 13 -- Press 'y' to try...

  • Complete the Rectangle Program Using the code given in rectangle.cpp, implement the functions that are called...

    Complete the Rectangle Program Using the code given in rectangle.cpp, implement the functions that are called in the main function to complete the program. You must not change any of the existing code in the file. You can only add functions and comments to the code. Here’s a sample run of how the program should behave: Enter rectangle length: -1 ← invalid value, ask user to re-enter Enter rectangle length: -2 ← invalid value Enter rectangle length: 0 ← invalid...

  • C# Design and implement a program (name it PalindromeInteger), to check if an integer value is...

    C# Design and implement a program (name it PalindromeInteger), to check if an integer value is a palindrome or not, using 2 methods (reverse and isPalindrome) specified as follows: Method reverse(int number) takes integer number and returns number in reverse order. The method mathematically reverses the number. Method isPalindrome(int number) takes integer number and returns true if the number is palindrome; false otherwise. Use method reverse() to implement method isPalindrome(). Notice that an integer value is palindrome if the value...

  • Do pseudocode in java Design (pseudocode) and implement (source code) a program (name it LargestOccurenceCount) that...

    Do pseudocode in java Design (pseudocode) and implement (source code) a program (name it LargestOccurenceCount) that read from the user positive non-zero integer values, finds the largest value, and counts it occurrences. Assume that the input ends with number 0 (as sentinel value to stop the loop). The program should ignore any negative input and should continue to read user inputs until 0 is entered. The program should display the largest value and number of times it appeared as shown...

  • Design (pseudocode) and implement (source code) a program (name it IncomeTax) that reads from the user...

    Design (pseudocode) and implement (source code) a program (name it IncomeTax) that reads from the user annual income, as integer value, and calculates the income tax based on the tax table below. Income Tax bracket Annual income <= $50,000 5% $50,000 < Annual income <= $200,000 10% $200,000 < Annual income <= $400,000 15% $400,000 < Annual income <= $900,000 25% $900,000 < Annual income 35% The program output should include the entered annual income followed by the applied tax...

  • C++Implement only (source code) a program to determine whether two two-dimensional arrays are equivalent or not....

    C++Implement only (source code) a program to determine whether two two-dimensional arrays are equivalent or not. Two arrays are equivalent if they contain the same values in any order. The program main method defines two two-dimensional array of size 3-by-3 of type integer, and prompts the user to enter integer values to initialize the arrays. The main method calls method isEquivalent()that takes two two-dimensional arrays of integer and returns true (boolean value) if the arrays contain the same values in...

  • This C++ Programs should be written in Visual studio 2017 PROGRAM 1: Comparing Using Arrays to...

    This C++ Programs should be written in Visual studio 2017 PROGRAM 1: Comparing Using Arrays to Using Individual Variables One of the main advantages of using arrays instead of individual variables to store values is that the program code becomes much smaller. Write two versions of a program, one using arrays to hold the input values, and one using individual variables to hold the input values. The programs should ask the user to enter 10 integer values, and then it...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT