Question

Create a C# Console Application named Front that creates a new string from a user's entry....

Create a C# Console Application named Front that creates a new string from a user's entry. Take the first 3 characters of the given string and return the string with the 3 characters added at both the front and back. If the given string length is less than 3 do not accept the string

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

CODE:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Front
{
    class Program
    {
        static void Main(string[] args)
        {
            string inputStr;// the string to be used as input
            string chars;// the string that holds the first three characters of the input string
            Console.WriteLine("Enter a string:");// prompt to enter a string
            inputStr = Console.ReadLine();// reading a string
            if ((inputStr.Trim().Length < 3))// checking the length of the input string
            {
                Console.WriteLine("Enter a valid string of length at least 3 characters..");
            }
            else
            {
                chars = inputStr.Substring(0, 3);// get the first three chars of the input string
                inputStr = chars + inputStr + chars;// appending the chars at the front and the back of the string
          
            }
            Console.WriteLine(inputStr);// writing the output string
            Console.ReadLine();// to hold the output window
        }
    }
}

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
Create a C# Console Application named Front that creates a new string from a user's entry....
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
  • Create the function front33 that accepts a string as an argument. The first three letters of...

    Create the function front33 that accepts a string as an argument. The first three letters of the string are added to the front of the string and at the end of the string. If the string length is less than 3, use whatever chars are present. The function takes a string character and returns a new string taking the first three characters of the input string and adding them to the front and the back of the string. (must be...

  • Write a C++ console application that reverses an array of characters, and counts the number of:...

    Write a C++ console application that reverses an array of characters, and counts the number of:           Lower case characters (islower)           Upper case characters (isupper)           Digits (isdigit)           Other (not one of previous) Create four global variables to hold these counts. Create function void count(char input[], char reverse[]) that takes as input two arrays: one that contains characters and another that will contain the reverse of that array. The function will reverse the input array and do the...

  • In C++, create a recursive bool function which determines if a string is symmetrical or not....

    In C++, create a recursive bool function which determines if a string is symmetrical or not. A symmetrical string can be read the same front to back (ex. kayak). Function Blueprint --------------------- bool isSymmetrical(string s) if (s is the empty string or s is of length 1) return true else if (s's first and last characters are the same letter)   return isSymmetrical (s minus its first and last characters) else return false

  • Please help me with these two problems. Thank you. Part A Create a console-based application that...

    Please help me with these two problems. Thank you. Part A Create a console-based application that prompts the user to enter the total price of the transaction as well as a sale or discount percentage, then returns the price of the transaction with the percentage discount applied. You should create at least one method that accepts and returns data. Part B Create a console-based application named MealPrice that computes the price of a meal at a pirate-themed restaurant owned by...

  • In entry level form Develop a C# console application that computes the hypotenuse of a right...

    In entry level form Develop a C# console application that computes the hypotenuse of a right triangle. The computation of the hypotenuse of a right triangle is based on the Pythagorean Theorem: c2 = a2 + b2 and the hypotenuse, c ("long side") of the triangle can be computed with the formula the hypotenuse is equal to the square root of the side a squared plus side b squared. The application should take as many side pairs inputs as the...

  • Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class...

    Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class should contain the following data fields and methods (note that all data and methods are for objects unless specified as being for the entire class) Data fields: A String object named firstName A String object named middleName A String object name lastName Methods: A Module2 constructor method that accepts no parameters and initializes the data fields from 1) to empty Strings (e.g., firstName =...

  • Include outputs. Write a C# console application named Tape that includes fields for length and width...

    Include outputs. Write a C# console application named Tape that includes fields for length and width in inches and properties for each field. Also include a ToString() method that returns a string constructed from the return value of the object's GetType() method and the values of the length and width fields. Derive two subclasses - VideoCassetteTape and AdhesiveTape. The VideoCassetteTape class includes an integer field to hold playing time in minutes - a value from 1 to 180 - and...

  • // Retire.cpp : Defines the entry point for the console application. // program to convery years...

    // Retire.cpp : Defines the entry point for the console application. // program to convery years to retire // sumin Kang // 9/26/17 #include "stdafx.h" #include <iostream> #include <iomanip> #include <string> #include <fstream> using namespace std; int main() { //declare files ifstream inFile; ofstream outFile; // declare constants and variables string name; int age; int ageInRetire; // open files inFile.open("D:\\retire"); outFile.open("D:\\retire"); // get input from user cout << "What is your name?"; getline(inFile, name); cout << "How old are you?";...

  • FOR JAVA: Summary: Write a program to assess password stringency. The solution should be named Password.java....

    FOR JAVA: Summary: Write a program to assess password stringency. The solution should be named Password.java. Include these steps: Write an application that provides the criteria for a strong password, and accepts a user's password from an input dialog box. If the entered password is less than six characters, more than 10 characters, or does not contain at least one uppercase letter and one digit, prompt the user to enter again. When the user's entry meets all the password requirements,...

  • Create an application that tracks electric motors in a manufacturing plant (Python and C++). The application...

    Create an application that tracks electric motors in a manufacturing plant (Python and C++). The application should have a Motor class with the following properties: MotorId: Five digit string, such as "02340" Description: String RPM: Double, values in the range 10 to 10000 Voltage: Double, values in the range 1 to 500 Status: String, three characters The Status values are: ON: Motor is online and running OFF: Motor is online but not running MNT: Motor is undergoing maintenance and cleaning...

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
ADVERTISEMENT