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
Paladinen [302]
3 years ago
5

The program DebugTwo2.cs has syntax and/or logical errors. Determine the problem(s) and fix the program.// This program greets t

he user// and multiplies two entered valuesusing System;using static System.Console;class DebugTwo2{static void main(){string name;string firstString, secondSting;int first, second, product;Write("Enter your name >> );name = ReadLine;Write("Hello, {0}! Enter an integer >> ", name);firstString = ReadLine();first = ConvertToInt32(firstString);Write("Enter another integer >> ");secondString = Readline();second = Convert.ToInt(secondString);product = first * second;WriteLine("Thank you, {1}. The product of {2} and {3} is {4}", name, first, second, product);}}
Computers and Technology
1 answer:
Elenna [48]3 years ago
5 0

Answer:

The corrected code is as follows:

using System;

using static System.Console;

class DebugTwo2{

     static void Main(string[] args){

       string name;string firstString, secondString;

       int first, second, product;

       Write("Enter your name >> ");

       name = ReadLine();

       Write("Hello, {0}! Enter an integer >> ", name);

       firstString = ReadLine();

       first = Convert.ToInt32(firstString);

       Write("Enter another integer >> ");

       secondString = ReadLine();

       second = Convert.ToInt32(secondString);

       product = first * second;

       Write("Thank you, {0}. The product of {1} and {2} is {3}", name,first, second, product);

   }

}

Explanation:

       string name;string firstString, secondString; ----- Replace secondSting with secondString,

<em>        int first, second, product;</em>

       Write("Enter your name >> "); --- Here, the quotes must be closed with corresponding quotes "

       name = ReadLine(); The syntax of readLine is incorrect without the () brackets

<em>        Write("Hello, {0}! Enter an integer >> ", name);</em>

<em>        firstString = ReadLine();</em>

       first = Convert.ToInt32(firstString); There is a dot between Convert and ToInt32

<em>        Write("Enter another integer >> ");</em>

       secondString = ReadLine(); --- Readline() should be written as ReadLine()

<em>        second = Convert.ToInt32(secondString);</em>

<em>        product = first * second;</em>

       Write("Thank you, {0}. The product of {1} and {2} is {3}", name,first, second, product); --- The formats in {} should start from 0 because 0 has already been initialized for variable name

   }

}

You might be interested in
Cuthbert Industrials, Inc., prepares 3-year comparative financial statements. In Year 3, Cuthbert discovered an error in the pre
Lelechka [254]

Answer:

Restate financial statement for the first and second year.

Prepare financial statement of year 3 reflecting the effects of error from year one and two

Explanation:

A revision of the the entire financial statement from year one will be helpfull, when this is re-stated for the first and second year. Then in stating the amount of assets and liabilities carried into year three, the cummulative effect of the error from the previous two years should be reflected.

8 0
2 years ago
Identify way in which computer are used in personnel management
Lyrx [107]

The main roles of computer in human resource management are decreasing time complexity, flexibility, record keeping problem etc. HRM system process lots of data everyday with the help of computer. This data processed easily without any fear of data loss so computer a vital role in human resource management system. The usage of computer in human resource management can be usually referred to as management information system. It can also be called as human resource information system. Usually what a computer does, it converts all the data or we can say raw data into meaningful and usable information required by the manager to take decisions, and for planning and control.

please I need brainliest thanks

I hope this helps

4 0
3 years ago
Read 2 more answers
Create a brief program that demonstrates use of a Java exception. For example, you could use InputMismatchException and ask the
HACTEHA [7]

Answer:

Here is the program that demonstrates the use of JAVA exception:

import java.util.Scanner;  //to accept input from user

public class Main {  //class name

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

      Scanner input = new java.util.Scanner(System.in);  //creates Scanner class object to accept input from user

       int number1 = 0;  //stores the first integer value

       int number2 = 0;  //stores the second integer value

       while(true) {  //keeps looping until user enters integer value

           System.out.println("Enter 2 integers to perform addition: "); //prompts user to enter two integer values

           try {  //defines a chunk of code to check for errors        

               number1 = input.nextInt(); //reads input integer 1

               number2 = input.nextInt(); //reads input integer 2                  

               break;             }  

           catch (java.util.InputMismatchException e) { // defines a code chunk to execute if an error occurs in the try code chunk

              System.out.println("Input must be an integer "); //displays this message if user enters anything other than an integer value

              input.nextLine();              }         }  // reads input from user again until user enters both integer type values

       System.out.println("The sum is: " + (number1+number2));      }  } //if user enters 2 integers then computes and displays the sum of two integer values

Explanation:

The program uses InputMismatchException exception and asks the user to input two integers and computes the sum of two integers if user enters  integers otherwise an exception InputMismatchException is thrown and a error message Input must be an integer is displayed to the user if they input a string of letters instead o f integer values. Here while loop is used which keeps executing until user enters both the integer values. After the user enters correct values, the sum of the two integers are computed and result is displayed on output screen. The screenshot of program and its output is attached.

Another program asks the user to input an integer and the program executes correctly if they enter an integer but exception InputMismatchException is thrown with an error message that is is displayed to the user if they input a string of letters. Here is the program:

import java.util.Scanner;

public class Main {

   public static void main(String[] args) {

       Scanner input = new java.util.Scanner(System.in);

       int number1 = 0;          

       while(true) {

           System.out.println("Enter an integer value: ");        

           try {

               number1 = input.nextInt();  

               break;             }  

           catch (java.util.InputMismatchException e) {

              System.out.println("Input must be an integer ");

              input.nextLine();             }        }  

       System.out.println("The program executed correctly!");  } }

7 0
3 years ago
For most people, the most effective way to save is:
oksian1 [2.3K]
I would say it's by creating a spending budget. 
3 0
3 years ago
How has technology change in film?
Murljashka [212]
With digital technology, the storage method has changed and today it is much easier to handle and transport movies to theatres than in the past. Servers, hard disks and video tapes are being used to store movies and digital projectors are being used to screen them.
6 0
3 years ago
Read 2 more answers
Other questions:
  • You have received several trouble tickets from the employees in the warehouse for the stand-alone computers used to control vari
    14·1 answer
  • How would you classify an employee who communicates effectively, listens to coworkers, and makes good decisions?
    15·2 answers
  • Which payment type is best if you are trying to stick to a budget?
    10·2 answers
  • Which letter would appear in the third position of the standard wheel marking of a hard-grade wheel?
    10·2 answers
  • Determine the number of character comparisons made by the brute-force algorithm in searching for the pattern GANDHI in the text
    7·1 answer
  • Please help, I can't find the answer but I understand the topic.
    10·2 answers
  • Hello everyone! can anybody help me? i need help with computing.
    10·1 answer
  • How many assignments would you have failed without brainly?<br><br> lol.
    5·1 answer
  • What two names are given to the blinking vertical line?
    6·1 answer
  • The while loop is also known as what kind of a loop? entry-control loop operational loop infinite loop user-control loop
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!