1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Mkey [24]
3 years ago
3

"Create a program that allows the user to input a list of first names into one array and last names into a parallel array. Input

should be terminated when the user enters a sentinel character. The output should be a list of email addresses where the address is of the following form: [email protected]"

Computers and Technology
1 answer:
lidiya [134]3 years ago
3 0

Answer:

#include<iostream>

using namespace std;

int main()

{

   string f[50],l[50],str1,str;   //f[] will store firstnames and l[] lastnames

   int i;

   cout<<"Enter firstnames and enter # to stop\n";

   cin>>str;

   for(i=0;str!="#";i++)       //# will be the sentinel character

   {

       f[i]=str;

       cin>>str;

   }

   cout<<"Enter lastnames and enter # to stop\n";

   cin>>str1;

   for(i=0;str1!="#";i++)

   {

       l[i]=str1;

       cin>>str1;

   }

   int n=i;        //n wiill be number of elements in array

   cout<<"\nList of emails are : \n";

   for(i=0;i<n;i++)        //loop to print list of emails

   {

       cout<<f[i]<<"."<<l[i]<<"@mycollege.edu"<<endl;

   }

   return 0;

}

OUTPUT :

Please find the attachment below.

Explanation:

Two arrays are maintains which are f[] and l[]. f[] stores firstnames and l[] stores lastnames. First 2 loops are reading firstnames and lastnames which will break if '#' is typed as it is considered as a sentinel character here which is assured by checking the condition in the loop. Then n variable is used to store the length of the arrays. Both arrays have to be of equal length as email ids contains both firstname and lastname. Then a loop is created to print email ids of the format specified by using arrays f[] and l[].

You might be interested in
public class Test { public static void main(String[] args) { try { method(); System.out.println("After the method call"); } catc
USPshnik [31]

Answer:

"ArithmeticException" is the correct answer for the above question.

Explanation:

Missing Information : The above question does not hold that "what is the output of the program".

  • The above question has a class that holds the two functions one function is the main function which calls the other function in a try-catch block.
  • The method function holds one run time exception which is 1/0 which is an arithmetic exception.
  • It can be handle by the help of an arithmetic class object which is defined in the first catch block.
  • Hence the print function of this catch is executed and prints "ArithmeticException".
8 0
3 years ago
In C++ :
elena-s [515]

Answer::

//Program is written in C++ Programming Language

// Comments are used for explanatory purpose

#include

#include

#include

#include

using namespace std;

int main(){

ifstream file; // File stream object

string name; // To hold the file name

string inputLine; // To hold a line of input

int lines = 0; // Line counter

int lineNum = 1; // Line number to display

// Get the file name.

cout << "Enter the file name: ";

getline(cin, name);// Open the file.

file.open(name.c_str());// Test for errors.

if (!file){

// There was an error so display an error

// message and end the PROGRAM.

cout << "Error opening " << name << endl;

exit(EXIT_FAILURE);

}

// Read the contents of the file and display

// each line with a line number.

// Get a line from the file.

getline(file, inputLine, '\n');

while (!file.fail()){

// Display the line.

cout << setw(3) << right << lineNum<< ":" << inputLine << endl;

// Update the line DISPLAY COUNTER for the next line.

lineNum++;// Update the total line counter.

lines++;// If we've displayed the 24th line, pause the screen.

if (lines == 24){

cout << "Press ENTER to CONTINUE...";

cin.get();

lines = 0;

}

// Get a line from the file.

getline(file, inputLine, '\n');}

//Close the file.

file.close();

return 0;}

8 0
4 years ago
You have been given two classes, a Main.java and a Coin.java. The coin class represents a coin. Any object made from it will hav
11111nata11111 [884]

Answer:

Here is the Coin class:

public class Coin {  //class names

 private int value;  // private member variable of type int of class Coin to store the value

 private String coinName;  // private member variable of type String of class Coin to store the coint name

 private double weight;      //private member variable of type double of class Coin to store the weight

  public void setValue (int v) {  //mutator method to set the value field

    value = v;  }  

     

 public void setName(String n){  //mutator method to set coinName field

    coinName = n;}  

 public void setWeight (double w) {  //mutator method to set weight field

    weight = w;  }  

 public int getValue () {  //accessor method to get the value

   return value;  }  // returns the current value

 

 public String getName () {  //accessor method to get the coin name

   return coinName;  }  //returns the current coin name

   

 public double getWeight () {   //accessor method to get the weight

   return weight;  } } //returns the current weight

 

Explanation:

Here is the Main.java

public class Main{ //class name

public static void main(String[] args) { //start of main method

Coin penny = new Coin(); //creates object of Coin class called penny

penny.setName("Penny");  //calls setName method of Coin using object penny to set the coinName to Penny

penny.setValue(1); //calls setValue method of Coin using object penny to set the coin value to 1

penny.setWeight(0.003); //calls setWeight method of Coin using object penny to set the coin weight to 0.003

   System.out.println("Coin name: " + penny.getName()); // calls getName method of Coin using penny object to get the current coin name stored in coinName field    

   System.out.println("Coin value: " + penny.getValue()); // calls getValue method of Coin using penny object to get the coin value stored in value field    

   System.out.println("Coin weight: " +penny.getWeight()); }} // calls getWeight method of Coin using penny object to get the coin weight stored in weight field    

The value of coinName is set to Penny, that of value is set to 1 and that of weight is set to 0.003 using mutator method and then the accessor methods to access these values and prinln() to display these accessed values on output screen. Hence the output of the entire program is:

Coin name: Penny                                                                                                                                Coin value: 1                                                                                                                                   Coin weight: 0.003

The screenshot of the program along with its output is attached.

3 0
3 years ago
_____ consists of computer programs that govern the operation of a computer.
telo118 [61]
Hello <span>Siyujiang8092</span>

Answer: Software<span> consists of computer programs that govern the operation of a computer.

Hope that helps
-Chris</span>
6 0
4 years ago
Supermarket managers who use scanners on the checkout counters to track inventory levels of their products are using a(n) ______
lidiya [134]
Operation Information System, because you are only collecting data on the amount of products leaving the store.
6 0
4 years ago
Other questions:
  • Assume that to_the_power_of is a function that expects two int parameters and returns the value of the first parameter raised to
    11·1 answer
  • 100 students were asked to fill out a form with three survey questions, as follows: H: Honor Roll C: Club membership (Robotics C
    7·1 answer
  • The acronym ________ is used by programmers to refer to the fact that computers cannot tell difference between good and bad data
    8·2 answers
  • Baris script yang digunakan mendefinisikan website yang akan diblokir proxy server adalah
    5·1 answer
  • If a user wants to add an expansion card to increase the memory of a computer, where should the user insert the card?
    12·2 answers
  • Justin bought some yarn from his favorite craft store. He can make 1 scarf with 3/5 of a ball of yarn. If he purchases 15 balls
    14·1 answer
  • An algorithm is a step by step process that describes how to solve a problem and/or complete a task, which will always give the
    14·1 answer
  • Which step of the problem-solving process did the farmer use in order to figure out what success would look like?
    7·1 answer
  • Task queues, which allow for asynchronous performance, are an important part of modern processing architectures. Information abo
    13·1 answer
  • which command entered without arguments is used to display a list of processes running in the urrent shell
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!