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
What is the purpose of a email
jasenka [17]

Answer:

An email is a digital message sent electronically from one computer to one or more other computers. Emails are flexible and can be used for giving instructions, serving as documentation, providing confirmation, communicating rules and procedures, making recommendations, providing a status update, making an inquiry.

7 0
3 years ago
Read 2 more answers
Is it ok to give a website your zip code?
Salsk061 [2.6K]
When a website takes in personal information from a user, the owners of the website have no idea what was input, no matter how hard they tried. The information is not stored, and is used by Javascript APIs to locate your address to either ensure that it is valid, or so that you can choose your address.

It's completely safe, and if a website looks really, really sketchy, then just don't give them anything personal.

Another way to identify if a website is safe to give your personal information to is if you see "HTTPS" in the URL at the top of your browser. This means Hyper Text Transfer Protocol Secure, and is the protocol used to transfer information over the internet SECURELY, via encryption that only computers are able to decrypt, and will not show that information to owners of the server/website.
5 0
3 years ago
Write an algorithm and draw a flowchart for switching off a machine after it has made 500 glass bottles. use an appropriate cond
masha68 [24]

The algorithm is as follows:

1. Start

2. bottles = 0

3. While bottles != 500

3.1 Create bottle

3.2 bottle = bottle + 1

4. Switch off machine

5. Stop

Explanation:

This begins the algorithm

1. Start

This initializes bottles to 0

2. bottles = 0

The loop is repeated until 500 bottles is created

3. While bottles != 500

This creates a new bottle

3.1 Create bottle

This increments the number of bottles by 1

3.2 bottle = bottle + 1

This switches of the machine after all bottles are created

4. Switch off machine

End algorithm

5. Stop

THANKS

4 0
3 years ago
Write a class called MagicSquare, which contains a single method called check that accepts a two-dimensional array as an argumen
ira [324]

Answer:

public class MagicSquare {

   public static void main(String[] args) {

       int[][] square = {

               { 8, 11, 14, 1},

               {13, 2, 7,12},

               { 3, 16, 9, 6},

               {10, 5, 4, 15}

       };

       System.out.printf("The square %s a magic square. %n",

               (isMagicSquare(square) ? "is" : "is not"));

   }

   public static boolean isMagicSquare(int[][] square) {

       if(square.length != square[0].length) {

           return false;

       }

       int sum = 0;

       for(int i = 0; i < square[0].length; ++i) {

           sum += square[0][i];

       }

       int d1 = 0, d2 = 0;

       for(int i = 0; i < square.length; ++i) {

           int row_sum = 0;

           int col_sum = 0;

           for(int j = 0; j < square[0].length; ++j) {

               if(i == j) {

                   d1 += square[i][j];

               }

               if(j == square.length-i-1) {

                   d2 += square[i][j];

               }

               row_sum += square[i][j];

               col_sum += square[j][i];

           }

           if(row_sum != sum || col_sum != sum) {

               return false;

           }

       }

       return d1 == sum && d2 == sum;

   }

}

5 0
3 years ago
Write a recursive definition of x^n, where n≥0, similar to the recursive definition of the Fibonacci numbers. How does the recur
Levart [38]

Answer:

Following are the program to this question:

#include <iostream>//defining header file

using namespace std;

int recurs(int x, int n)//defining a method recurs that accepts two parameter

{

if(n==0)//defining if block that checks n value

{

return 1;//return value 1

}

else//defining else block

{

return x*recurs(x,n-1);//use return keyword that retun value

}

}

int main()//defining main method

{

cout<<recurs(5,3); //use print method to call recurs method

   return 0;

}

Output:

125

Explanation:

In the above-given program, the integer method "recurs" is declared which accepts, two integer variables, which are "x, n", inside the method the if conditional statement is used.

  • In the if block, it checks the value of n is equal to "0" if this condition is true, it will return a value, that is 1.
  • Otherwise, it will go to the else block, in this block, it will use the recursive method to print its value.    
5 0
3 years ago
Other questions:
  • A ________ pays out cash flows from a collection of assets in different tranches, with the highest-rated tranch paying out first
    8·1 answer
  • show how one version of the technology is an improvement over a previous iteration of that same technology
    11·1 answer
  • What is the output of the following program? #include using namespace std; class TestClass { private: int val; void showVal() {
    5·1 answer
  • When you take a multiple-choice test, you are relying on ________, a means of retrieving information out of your long-term memor
    8·1 answer
  • Compare and contrast system software and generalised software
    11·1 answer
  • [1] Our son has started playing organized T-ball, a beginner’s version of baseball. [2] “Organized” is what parents call it, any
    9·2 answers
  • Do you guys know if there's a way for me to find a Google doc that I typed but forgot to save if you do it for points i will rep
    10·2 answers
  • PLS HURRRYYYYYY!1!1!1!1!1
    5·2 answers
  • Accenture has put together a coalition of several ecosystem partners to implement the principles of blockchain and Multi-party S
    5·1 answer
  • Write an if statement that assigns 0.2 to commission if sales is greater than or equal to 10000.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!