Microsoft Visual C#
7th Edition
ISBN: 9781337102100
Author: Joyce, Farrell.
Publisher: Cengage Learning,
expand_more
expand_more
format_list_bulleted
Question
The program will ask the user for their name and employee ID. The ID will be a five-digit number. This will be done in a single function, AskNameId, with bool return, where the name and id are passed as pointers. Read both variables as strings with a getline and convert the id to an int using atoi. Check that the id is not 0. If it is, cout a message to the user for entering an invalid id. Check if the name is an empty string. If it is, cout a message to the user for entering an invalid name. Return a bool, true if name and id are both valid and false if either one is not valid.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Implement a function named get_player_selection. This function has parameters for the players number (which will be either 1 or 2), and the number of sticks remaining on the board. For this function you will need to do the following: Use the input function to get the player to type in their selection. Validate the user’s input, printing out a message if they enter an invalid number and continually prompting them until they do enter a valid number. The user may enter any number between 1 and 3, unless there are fewer than 3 sticks remaining, in which case they can only enter between 1 and the number of sticks remaining. As in the example, the input prompt should list the valid range of numbers. Return the (validated) number as an integer (not a string). You should test that this function works by running it in the REPL. Make sure you try different scenarios, like the user entering an invalid number multiple times in a row. After you are done testing and fixing any errors you find,…arrow_forwardWrite a program that paints the 4 areas inside the mxm square as follow: Upper left: black. RGB (0, 0, 0) Upper right: white. RGB (255, 255, 255) Lower left: red. RGB (255, 0, 0) Lower right: random colors Random colors Hint: Define a function that paints one of the four squares. Call the function 4 times to complete the painting. (painting means setting the pixels)arrow_forwardCreate a program that: 1. Prompts the user to enter a string. 2. Use ANY method you'd like to remove all the vowels from the string (string function substring, accessing the string characters as arrays, etc.), creating a new string. 3. Output the new string with all the vowels removed. 4. The program MUST contain two functions-- (1) to remove all the vowels from the string, i.e., create a new string from the old string; (2) to determine if a character is a vowel. 5. Use an enumerated type to evaluate each character to determine if it is a vowel. Hint: Write the program WITHOUT the enumerated type first to get it working.arrow_forward
- Complete the convert() function that casts the parameter from a float to an integer and returns the result.Note that the returned value of the convert() function is printed. Ex: If the float value is 19.9, then the output is: 19 Ex: If the float value is 3.1, then the output is: 3 this is what i have def largest_number(num1, num2, num3): if(num1 > num2 and num1 > num3): return num1 elif(num2 > num3): return num2 else: return num3 def smallest_number(num1, num2, num3): if(num1 < num2 and num1 < num3): return num1 elif(num2 < num3): return num2 else: return num3 if __name__ == '__main__': n1 = float(input()) n2 = float(input()) n3 = float(input()) print("largest:",largest_number(n1,n2,n3)) print("smallest:",smallest_number(n1,n2,n3)) it says Test convert() with random float value test_passed function missing Traceback (most recent call last): File "main.py", line 18, in <module> n1 = float(input()) EOFError: EOF when reading a line Your output Your…arrow_forwardSome of the earliest computer games developed were Interactive Fiction games, in which the user’s environment is described in text, and the user makes choices using text commands. In this problem and the next one, we’ll be developing a very simple text-based adventure game. Every choice in this game will have exactly three options, so we can write a function that works for any of them. Write a function selection(text, optionA, optionB, optionC), that takes in four string values. text is a string representing a prompt in a text adventure game, and optionA, optionB, and optionC are strings representing the three possible options. The function should print out the text, and then print out the options (label them with A., B., and C.). Next, the input() function should be used to prompt the user to choose A, B, or C. Then the function should return (not print) the one character string that represents the user’s choice: 'A', 'B', or 'C'. If the user does not choose one of those…arrow_forwardATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but exactly 4 digits or exactly 6 digits. Your task is to create a function that takes a string and returns true if the PIN is valid and false if it's not. Examples validatePIN("1234") ➞ true validatePIN("12345") ➞ false validatePIN("a234") ➞ false validatePIN("") ➞ false Notes ● Some test cases contain special characters. ● Empty strings must return false.arrow_forward
- Complete the rotate_text() function that takes 2 parameters, a string data and an integer n. If n is positive, then the function will shift all the characters in data forward by n positions, with characters at the end of the string being moved to the start of the string. If n is 0 then the text remains the same. For example: rotate_text('abcde', rotate_text('abcde', rotate_text('abcde', 1) would return the string 'eabcd' 3) would return the string 'cdeab' 5) would return the string 'abcde' rotate_text('abcde', 6) would return the string 'eabcd' ... and so on. If n is negative, then the function will shift the characters in data backward by n positions, with characters at the start of the string being moved to the end of the string. For example: rotate text('abcde', -1) would return the string 'bcdea'arrow_forwardWrite a program called palindrome.cpp. The program should have the two functions listed below. Your program should loop until the user enters “quit". The determination of a word being a palindrome or not should be case insensitive. void getWord ( string& word ): This function is responsible for getting the word from the user. void isPalindrome ( string& word, bool& result ): This function is responsible for determining if a word is a palindrome or not. It will return true if the word is a palindrome and false if the word is not a palindrome using a boolean variable passed by reference. Sample Output 1 What is the word? Kayak Kayak is a palindrome Sample Output 2 What is the word? APPLE APPLE is not a palindrome Notes • Remember that you can access each character in a string by using the index operator, i.e., word[3], and the highest index of any string is the length of the string minus one. • To handle the case-insensitivity part you may need to work with functions that change the case…arrow_forwardPlease help me complete this project. I am very confused and lost. The main() function for this project is in Arithmetic.cpp; it queries the end user for a string arithmetic expression. The main() function calls the eval() function to evaluate and return the result of the arithmetic expression passed as a parameter. Lastly, the main() function displays the result to the end user. Any number of expressions may be evaluated. The main() function is completed. You are responsible for the implementation of the eval() function. The eval() function parameter will be a string consisting of a properly formed arithmetic expression using only the values 0 through 9 and + (addition), - (subtraction), * (multiplication), / (division), and/or ^ (exponentiation) operators. The expression will not include decimals, negative values, or values above 9. The expression will not include parenthesis but may include spaces, which should be skipped. The eval() function needs to use two ArrayStacks:…arrow_forward
- Print person1's kids, apply the IncNumKids() function, and print again, outputting text as below. End each line with a newline.Sample output for below program with input 3:Kids: 3 New baby, kids now: 4arrow_forwardSuppose that first and last names are two arguments. Write a function initials_switch. You can send the method either one string containing first and last, or a separate string for first and a separate string for last (whichever you prefer) For example, if first = "Keanu" and last = "Reeves" the code will print Keanu Reeves. Test your function works like this for Keanu Reeves, and then another first and last name.arrow_forwardwrite a program in python Write a program that will allow a student to enter their name and then ask them to solve 10 mathematical equations. The program should display two random numbers that are to be added, such as: 247 + 129 The program should allow the student to enter the answer. The program should then display whether their answer was right or wrong, and accumulate the right values. After the 10 questions are asked, calculate the average that was correct. Then display the student name, the number correct, and the average correct in both decimal and percentage format. In addition to any system functions you may use, you might consider the following functions: A function that allows the student to enter their name. A function that gets two random numbers, anywhere from 1 to 500. A function that displays the equation and asks the user to enter their answer. A function that checks to see if the answer is correct and accumulates the number correct. A function that calculates the…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,