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
The piece of hardware that contains the circuitry that processes the information coming in to the computer and tells the other h
Gemiola [76]

The answer is C. Central processing unit (or CPU).

The trick is in the name, central processing unit :)

3 0
3 years ago
Compare and contrast system software and generalised software
jekas [21]
System software is a type of computer program that is designed to run a computer’s hardware and application programs.
Generalized software refers to software designed to read, process and write data with the help of functions performing specific audit routines and with self-made macros.
3 0
3 years ago
Write a function listLengthOfAllWords which takes in an array of words (strings), and returns an array of numbers representing t
vesna_86 [32]

Answer:

   public static int[] listLengthOfAllWords(String [] wordArray){

       int[] intArray = new int[wordArray.length];

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

           int lenOfWord = wordArray[i].length();

           intArray[i]=lenOfWord;

       }

       return intArray;

   }

Explanation:

  1. Declare the method to return an array of ints and accept an array of string as a parameter
  2. within the method declare an array of integers with same length as the string array received as a parameter.
  3. Iterate using for loop over the array of string and extract the length of each word using this statement  int lenOfWord = wordArray[i].length();
  4. Assign the length of each word in the String array to the new Integer array with this statement intArray[i]=lenOfWord;
  5. Return the Integer Array

A Complete Java program with a call to the method is given below

<em>import java.util.Arrays;</em>

<em>import java.util.Scanner;</em>

<em>public class ANot {</em>

<em>    public static void main(String[] args) {</em>

<em>       String []wordArray = {"John", "James", "David", "Peter", "Davidson"};</em>

<em>        System.out.println(Arrays.toString(listLengthOfAllWords(wordArray)));</em>

<em>        }</em>

<em>    public static int[] listLengthOfAllWords(String [] wordArray){</em>

<em>        int[] intArray = new int[wordArray.length];</em>

<em>        for (int i=0; i<wordArray.length; i++){</em>

<em>            int lenOfWord = wordArray[i].length();</em>

<em>            intArray[i]=lenOfWord;</em>

<em>        }</em>

<em>        return intArray;</em>

<em>    }</em>

<em>}</em>

This program gives the following array as output: [4, 5, 5, 5, 8]

7 0
3 years ago
Maria works for MegaCorp, a large privately owned company specializing in sales of ball bearings. MegaCorp introduces filtering
ololo11 [35]

Answer:

No, because it would be generally free for private-sector employees by using filtering software to restrict access to some websites.

Explanation:

Maria working for the following Corporation, a major private-owned company that specializes throughout ball bearings production. That corporation establishes filtering software to restrict access to some of these sites linked to non-work, and also some sites with poπnographic images.

So, Maria could not challenge that policy lawfully, as private-sector employees are usually free to always use filtering software to restrict access to some of these Websites

3 0
3 years ago
What is one property of a good hash code?
larisa [96]

Answer:- Major property of a good hash code is that objects which are equal should return the same hash code .

Explanation: Hash codes is a numeric value which  is used for identify a object while a equality testing .Hash code can occupy the value of any length and then returns a fixed length value. The value of hash codes are variable.

If two objects are equal then by the method of equal(object) if the hashcode() function is called on both the objects , they produce the same value.

8 0
3 years ago
Other questions:
  • The _____ command icon looks like a small clipboard with a page attached.
    6·1 answer
  • Consider the attack scenario given below:
    8·1 answer
  • Which principle of animation deals with imparting a unique identity to the animated character?
    5·1 answer
  • Write a program which:
    10·1 answer
  • After a suspected identity fraud case has been resolved, you should:
    5·1 answer
  • printLarger is a method that accepts two int arguments and returns no value. Two int variables, sales1 and sales2, have already
    11·1 answer
  • Which is not one of the four criteria for proving the correctness of a logical pretest loop construct of the form: while B do S
    14·1 answer
  • How can your network be infected with malware or ransomware?
    6·1 answer
  • Remember not to use tools that are ________ in any way.
    5·1 answer
  • . A binary search has a right subtree but no left subtree. What noes contains that least element in the tree
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!