Question

In: Computer Science

3. [1 pts] Part A. Write a program for the GW Admissions Office. a) Request the...

3. [1 pts] Part A. Write a program for the GW Admissions Office. a) Request the staff to enter a string, to indicate someone’s NetID. b) Generates an email address, by appending “@gwmail.gwu.edu” to the user input c) Print the generated email account [2 pts]

Part B. Write a program to meet additional requirements. In addition to requirements in Part A, your function should perform the following check: a) If the user input is longer than 10 characters (11 or more), truncate it and use the first 10 characters to generate an email address. Print the email address.

Solutions

Expert Solution

Program in c++ Part A:

#include <iostream>
#include<string.h>
using namespace std;

int main()
{
string s="@gwmail.gwu.edu"; // given in program
string str;
string email1;
cout<<"Please Enter a String"<<endl;
getline(cin, str);// input string
email1=str+s; //generate email by appending input string and given string
cout<<"Generated email is: "<<email1<<endl;//print string
return 0;
}

Output 1:

Part A Screenshot

Program in c++ part B:

#include <iostream>
#include <string.h>
using namespace std;

int main()
{
string s="@gwmail.gwu.edu";// given string
string str;
string email;
cout<<"Please Enter a String"<<endl;
getline(cin, str);// input string
int len;
len=str.length(); // find length of string
if(len>10){// is length is grater then 10
string str1=str.substr(0,10);// create substring of length 10
email=str1+s;// //generate email by appending string with length 10 and given string
}
else{
email=str+s; //generate email by appending input string and given string
}
cout<<"Generated email is: "<<email<<endl;// print string
return 0;
}

Output 1:

Part B Screenshot


Related Solutions

Part 2: MATLAB Exercise 1 (50 pts) Write a program that tells the user if a...
Part 2: MATLAB Exercise 1 (50 pts) Write a program that tells the user if a city of their choice is in a tropical, temperate, or polar region. Use the cities.txt file provided in the Files section of this class. Your program should read the data in that file, find the city given by the user, and return a text message with the information. If the city is not found, your program should write a message accordingly. To decide which...
Need to write a program and part 1 of the program is to write an HTML...
Need to write a program and part 1 of the program is to write an HTML code, here are the parameters, but I am new to HTML and I am confused as to how to write this. 1) HTML file shall:         - have your name(s) somewhere near the top, as a comment.         - be a complete html document with appropriate html tags.         - have 1 form with 2 parts, described as follows:         part 1:             -...
Previously, you wrote a program named Admission for a college admissions office in which the user...
Previously, you wrote a program named Admission for a college admissions office in which the user enters a numeric high school grade point average and an admission test score. The program displays Accept or Reject based on those values. Now, create a modified program named AdmissionModularized in which the grade point average and test score are passed to a method that returns a string containing Accept or Reject. CODE: using System; using static System.Console; class Admission {    static void Main()...
Write a program that request a time interval in seconds and display it in hours, minutes,...
Write a program that request a time interval in seconds and display it in hours, minutes, second format. (java)
1. (50 pts) Write a C program that generates a 2D array-of-double and finds the indexes...
1. (50 pts) Write a C program that generates a 2D array-of-double and finds the indexes of the largest value stored in the 2D array. Specific requirements: (1) Your main function defines the 2D array a. You will need to prompt the user to specify the size of the 2D array b. You will need to prompt the user to put in numbers to initialize the array (2) Write a function to display the array that is visualized as rows...
Suppose ?(?, ?) = ?3? a) (3 pts) Write down the formula and calculate the marginal...
Suppose ?(?, ?) = ?3? a) (3 pts) Write down the formula and calculate the marginal rate of substitution (MRS) of X for Y. b) (1 pts) Denote the price for good X is ? , the price for good Y is ? , and income is I.?? Write down the budget constraint. c) (5 pts) Derive the individual demand for good X and good Y as a function of prices and income. (hint: solve the utility maximization problem) d)...
Write a MIPS Assembly language program to request a file name from the user, open the...
Write a MIPS Assembly language program to request a file name from the user, open the file, read the contents, and write out the contents to the console. This is what I have so far: .data    fileName:   .space 100    prompt1:   .asciiz "Enter the file name: "    prompt2:    .asciiz ""    prompt3:   .asciiz "\n"    buffer:    .space 4096 .text    main:        #        li $v0, 4        la $a0, prompt1       ...
Part 1: Write a program that finds the sum and average of a series of numbers...
Part 1: Write a program that finds the sum and average of a series of numbers entered by the user. The program will first ask the user how many numbers there are. It then prompts the user for each of the numbers in turn and prints out the sum, average, the list of number from the user. Note: the average should always be a float, even if the user inputs are all ints. Part 2: Same as part 1 except...
C Program 1. Write a program that prompts the user to enter 3 integers between 1...
C Program 1. Write a program that prompts the user to enter 3 integers between 1 and 100 from the keyboard in function main and then calls a function to find the average of the three numbers. The function should return the average as a floating point number. Print the average from main.The function header line will look something like this:float average(int n1, int n2, int n3) STOP! Get this part working before going to part 2. 2. Create a...
MATLAB QUESTION Write a python program to request a positive float input from the user, x....
MATLAB QUESTION Write a python program to request a positive float input from the user, x. The program should check for the value of x. If x is larger than or equal to 1.0, the program should display the value of x in addition to the string “is larger than or equal to 1” and then terminate the program. If x is less than 1 the program should calculate y such that: y = 1-x+x^2/2-x^3/3+x^4/4-x^5/5……-x^99/99+x^100/100 The program should then display...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT