Question

In: Computer Science

Please code C# 10. Write a program that allows a user to input names and corresponding...

Please code C#

10.

  1. Write a program that allows a user to input names and corresponding heights (assumed to be in inches). The user can enter an indefinite number of names and heights. After each entry, prompt the user whether they want to continue. If the user enters true, ask for the next name and height. If the user enters false, display the name of the tallest individual and their height.

Sample run:

“Name?”

James

“Height?”

50

“Continue?”

True

“Name?”

Sarah

“Height?”

60

“Continue?”

False

“Sarah is the tallest at 60 inches”

Solutions

Expert Solution

Code is Given Below:

===========================

using System;
using System.Collections;
class HelloWorld {
static void Main() {
//creating array list to hold names and height
ArrayList names=new ArrayList();
ArrayList heights=new ArrayList();
  
  
while(true){
//asking user to enter data
Console.WriteLine("Name?");
string name=Console.ReadLine();
Console.WriteLine("Height?");
int height=Convert.ToInt32(Console.ReadLine());
names.Add(name);
heights.Add(height);
Console.WriteLine("Continue?");
string option = Console.ReadLine();
//checking if user want to continue or not
if(string.Equals(option, "True", StringComparison.OrdinalIgnoreCase))
continue;
else
break;
  
  
}
//finding person with maximum height in array list
int index=0;
int maxHeight=(int)heights[0];
for(int i=1;i<names.Count;i++ ){
if((int)heights[i]>maxHeight){
maxHeight=(int)heights[i];
index=i;
}
}
//displaying data
Console.WriteLine(names[index]+" is the tallest at "+maxHeight+" inches");
}
}

Output:

===============

Code Snapshot:

==============


Related Solutions

C++ Vector Write a program that allows the user to enter the last names of the...
C++ Vector Write a program that allows the user to enter the last names of the candidates in a local election and the votes received by each candidate. The program should then output each candidate's name, votes received by that candidate, and the percentage of the total votes received by the candidate. Assume a user enters a candidate's name more than once and assume that two or more candidates receive the same number of votes. Your program should output the...
Please write the code JAVA Write a program that allows the user to enter the last...
Please write the code JAVA Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes received by each candidate. The program should then output each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. A sample output is: Candidate      Votes Received                                % of Total Votes...
Using RAPTOR create a program that allows the user to input a list of first names...
Using RAPTOR create a program that allows the user to input a list of first names in on 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 address where the address is of the following form: [email protected]
Write a java code that allows the user to input any word/name from the console (10...
Write a java code that allows the user to input any word/name from the console (10 words/names only) and then sorts and alphabetizes them into an array without using predefined methods (.compareTo(), or any sorter functions) and then print out the results. you must have three methods that can: Compare multiple strings Swap elements Sort and alphabetize string ***REMEMBER DO NOT USE ANY PRE-DEFINED METHODS*** Example of how the code should work: Enter names/words (10 only): "james, john, alex, aaron,...
in C please! Write a code that asks user for input N and calculates the sum...
in C please! Write a code that asks user for input N and calculates the sum of the first N odd integers. There should be a "pure" method that calculates the sum separately that Main method should call when printing the output.
*Please write code in C++* Write a program to verify the validity of the user entered...
*Please write code in C++* Write a program to verify the validity of the user entered email address.   if email is valid : output the stating that given email is valid. ex: "The email [email protected] is valid" else : output the statement that the email is invalid and list all the violations ex:  "The email sarahwinchester.com is invalid" * @ symbol * Missing Domain name The program should keep validating emails until user enter 'q' Upload your source code. ex: main.cpp
Write a C++ Program Write a program that prompts the user to input a string. The...
Write a C++ Program Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. You must insert the following comments at the beginning...
Please code C# 8. Write a program that prompts the user to enter an integer. The...
Please code C# 8. Write a program that prompts the user to enter an integer. The program then determines and displays the following: Whether the integer is divisible by 5 and 6 Whether the integer is divisible by 5 or 6
IN C++ PLEASE Requirements Write a program that takes in user input of two integer numbers...
IN C++ PLEASE Requirements Write a program that takes in user input of two integer numbers for height and width and uses a nested for loop to make a rectangle out of asterixes. The creation of the rectangle (i.e. the nested for loop) should occur in a void function that takes in 2 parameters, one for height and one for width. Make sure your couts match the sample output (copy and paste from those couts so you don't make a...
​​​​​​​ASAP PLEASE Write a python code that prompts a user to input a 10-digit phone number....
​​​​​​​ASAP PLEASE Write a python code that prompts a user to input a 10-digit phone number. The output of your code is the phone number’s  area code, prefix and line number separated with a space on a single line e.g INPUT 2022745512 OUTPUT 202 274 5512 write a code that will prompt a user to input 5 integers and output its largest value. PYTHON e.g INPUT 2 4 6 1 3 OUTPUT Largest value is: 6
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT