
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
using System;
class Program
{
publicstaticvoid Main(string[] args)
{
int number,max=-9999999;
while (true)
{
Console.WriteLine("Enter a number: ");
number=Convert.ToInt32(Console.ReadLine());
if(number==0)
{
break;
}
else
{
if(number>max)
{
max=number;
}
}
}
Console.WriteLine("Largest number is "+max);
}
}
Hello! Hope you are well!
This C# program gets numbers from the user and prints the largest one. How can it be fixed to only ask for 6 numbers from the user and then choose the largest one?
Thank you!
![dron
StopI
main.cs
Console
Shell
using System;
> mcs -out:main.exe main.cs
> mono main.exe
class Program
3
Enter a number:
public static void Main(string[] args)
{
4
Enter a number:
4
6
int number, max=-9999999;
Enter a number:
7
while (true)
2
{
Console.Writeline("Enter a number: ");
number=Convert.ToInt32(Console.ReadLine());
if(number==0)
{
8
Enter a number:
11
10
Enter a number:
96
11
Enter a number:
12
5
13
break;
Enter a number:
14
}
1
15
else
Enter a number:
9
{
if(number>max)
{
16
Enter a number:
17
24
18
Enter a number:
19
max=number;
7
}
}
}
Console.WritelLine ("Largest number is "+max);
}
20
Enter a number:
21
32
Enter a number:
22
45
23
Enter a number:
24
25
86](https://content.bartleby.com/qna-images/question/6a85ba4d-6f5c-41bf-97e5-182adb23b838/8b518c2f-b4dd-4443-9c63-5ced6676c021/q3gyg6q_thumbnail.png)
Transcribed Image Text:dron
StopI
main.cs
Console
Shell
using System;
> mcs -out:main.exe main.cs
> mono main.exe
class Program
3
Enter a number:
public static void Main(string[] args)
{
4
Enter a number:
4
6
int number, max=-9999999;
Enter a number:
7
while (true)
2
{
Console.Writeline("Enter a number: ");
number=Convert.ToInt32(Console.ReadLine());
if(number==0)
{
8
Enter a number:
11
10
Enter a number:
96
11
Enter a number:
12
5
13
break;
Enter a number:
14
}
1
15
else
Enter a number:
9
{
if(number>max)
{
16
Enter a number:
17
24
18
Enter a number:
19
max=number;
7
}
}
}
Console.WritelLine ("Largest number is "+max);
}
20
Enter a number:
21
32
Enter a number:
22
45
23
Enter a number:
24
25
86
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps with 3 images

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
- In C++ Find the five errors. For each error, state the line number, explain the error and show a correction. #include<iostream> #include<iomanip> using namespace std; class colorCode { public: void setRGB(int); //accepts an int parameter and sets the RGB to the value of the parameter void setName(string);//accepts a string parameter and sets the name of the object to the value of the parameter string getName() const;//returns the name of the object int getRGB() const;//returns the RGB of the object void changeColor();// adds 10 to the RGB value private: string name; int RGB; } int main() { colorCode paintCans[10]; int i; for (i = 0; i < 10; i++){ paintCans.setRGB[i] = 0;} paintCans[5].setName(GREEN); paintCan[5].setRGB(192000); cout << paintCans[5].getName << ' ' << paintCans[5].getRGB() << endl; return 0; }arrow_forwardJava Input class main { publicstaticvoid main(String args[]) { boolean a =true; boolean b =false; boolean c = a ^ b; System.out.println(!c); } } Find output.arrow_forwardWrite a function getNeighbors which will accept an integer array, size of the array and an index as parameters. This function will return a new array of size 2 which stores the neighbors of the value at index in the original array. If this function would result in returning garbage values the new array should be set to values {0,0} instead of values from the array.arrow_forward
- PROBLEM STATEMENT: Use string concatenation to append the "dogs" string to the parameter str. public class StringConcatAppend{public static String solution(String str){// ↓↓↓↓ your code goes here ↓↓↓↓return null; Can you help me with this question The language is Javaarrow_forward#include using namespace std; int main() { } int kidsInClass1; int kidsInClass2; int numClasses; double kidsAvgMethodl; double kidsAvgMethod2; kidsInClass1= 3; kidsInClass2 = 2; numClasses = 2; Type the program's output kidsAvgMethodl = static_cast (kidsInClass1 + kidsInClass2) /static_cast (numClasses); kidsAvgMethod2 (kidsInClass1 + kidsInClass2) / numClasses; cout << kidsAvgMethod1 << endl; cout << kidsAvgMethod2 << endl; return 0; =arrow_forward}/*** Adds letterGuessed to the current String updateLetterBoard* @param usedLetterBoard* @param letterGuessed* @param first* @return updateLetterBoard with letterGuess appended. */public static String updateLetterBoard(String usedLetterBoard, char letterGuessed, boolean first) {return "";}arrow_forward
- 1 using System; 2 using System.Text; 3 class Program { staticvoid Main(string[] args) { int choice,games_choice; Console.WriteLine("You are on a quest for a rare flavor of chips you saw on an ad. The inside of the bag has an invaluable prize that could change your life forever. You decide to dedicate today to find that bag of chips. Do you go to Walmart or Costco first?"); Console.Write("Press 1 for 'Walmart' or Press 2 for 'Costco'\n"); choice = int.Parse(Console.ReadLine()); if(choice==1) { Console.WriteLine("You begin your meticulous search in the isles of the Walmart Supercenter only to find an empty display of the newly released rare flavor of chips. Out of the corner of your eye you see a nearby shopper with three bags of those rare chips in her basket casually strolling along. Craziness pops in your head and you have to make a quick decision. Your first option is to ask her nicely for one of the bags but that just seems far fetched. Your second option is to challenge her to a…arrow_forwardint x1 = 66; int y1 = 39; int d; _asm { } mov EAX, X1; mov EBX, y1; push EAX; push EBX; pop ECX mov d, ECX; What is d in decimal format?arrow_forwardPROBLEM STATEMENT: Return the longest String! public class LongestString{public static String solution(String firstWord, String secondWord){// ↓↓↓↓ your code goes here ↓↓↓↓return null;}} Can you help me with this Java Questionarrow_forward
- void fun(int i) { do { if (i % 2 != 0) cout =1); cout << endl; } int main() { int i = 1; while (i <= 8) { fun(i); it; } cout <arrow_forwardSee attached images C++arrow_forwardWhich kind of computer is more advanced, a traditional computer or a quantum computer, and what are the most noticeable distinctions between the two? What challenges must be met in the field of quantum computing before it can be called a success?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education