answer.
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
Vladimir79 [104]
1 year ago
9

When ____ occur during preliminary debugging, dummy print statements—statements that are temporarily inserted into the code to d

isplay status information on the screen—can be used to help locate the error.
Computers and Technology
1 answer:
ANEK [815]1 year ago
4 0

Answer:

Logic error.

Explanation:

When a logic error occurs sometimes it becomes difficult to locate the error in the code.So to locate the error dummy print used to see which loop,if,else,switch case etc. is executing or not.

for example:-

for(int i=0;i<45;i++)

{

if(i!=1)

{

   continue;

}

cout<<i<<endl;

}

we wanted the loop to print all value of i except 1 but it is printing only 1.We can use dummy print statement for this code in if condition.for(int i=0;i<45;i++)

{cout<<"Loop"<<endl;

if(i!=1)

{

cout<<"Printing"<<endl;

   continue;

}

cout<<i<<endl;

}

We see that the loop is printed 45 times and printing 44 times.We found that the condition in if statement is wrong.It hould be '==' instead of '!='.

You might be interested in
What does Josh Silverman name as the most important aspect of managing finances?
Andre45 [30]

The answer is a the first one

6 0
1 year ago
Read 2 more answers
Write a Java class with the following methods: getArray(int numStrings) is an instance method that takes command line input (use
mezya [45]

Answer:

Follows are the code to this question:

import java.util.*;//import packae for user-input  

public class Main//defining a class Main

{

public String[] getArray(int numString)//defining a method getArray

{

String[] name=new String[numString];//defining array of String values

Scanner in = new Scanner(System.in);// creating scanner class object for input values from user-end

for(int i=0;i<numString;i++)//defining for loop for input multiple values

{

System.out.print("Enter String Value :");//print message

name[i]=in.nextLine();//input values

}

return name;//return array values

}

public String getLongestString(String[] sArray)//defining a method getLongestString

{

int m=0,mi=0; //defining integer variables

for(int i=0;i<sArray.length;i++)//defining for loop for check the longest value in array

{

if(m<sArray[i].length())//defining if block that checks m varaible value greater then sArray length  

{

m=sArray[i].length();//use m to hold sArray length

mi=i;//use max_index to hold i that is loop value

}

}

return sArray[mi];//return Longest value

}

public static void main(String[] args)//defining main method

{

Main s=new Main();//Creating object of main class    

String[] n;//defining string variable n  

n=s.getArray(5);//use n varaible to call getArray method and store its value

System.out.println("Longest value is: "+s.getLongestString(n));//use print method to call getLongestString method

}

}

Output:

please find attached file.

Explanation:

In the given java program code, inside the main class two method that is "getArray and getLongestString", is defined, in which the "getArray" method uses an integer variable in its parameter and inside the method, an array is defined that use a  scanner class for input array value.

  • In the "getLongestString" pass as a parameter and inside the method, two integer variable "m and mi" is defined that use in the loop to return the longest string value.
  • In the class main method is to define that creates a class object and call the above method and use the print method to return its value.  

4 0
2 years ago
Write a function named file_stats that takes one string parameter (in_file) that is the name of an existing text file. The funct
Ivan

Answer:

Here is the Python program.

characters = 0

words = 0

lines = 0

def file_stats(in_file):

   global lines, words, characters

   with open(in_file, 'r') as file:

       for line in file:

           lines = lines + 1

           totalwords = line.split()

           words = words + len(totalwords)

           for word in totalwords:

               characters= characters + len(word)

file_stats('created_equal.txt')

print("Number of lines: {0}".format(lines))

print("Number of words: {0}".format(words))

print("Number of chars: {0}".format(characters))

   

Explanation:

The program first initializes three variables to 0 which are: words, lines and characters.

The method file_stats() takes in_file as a parameter. in_file is the name of the existing text file.

In this method the keyword global is used to read and modify the variables words, lines and characters inside the function.

open() function is used to open the file. It has two parameters: file name and mode 'r' which represents the mode of the file to be opened. Here 'r' means the file is to be opened in read mode.

For loop is used which moves through each line in the text file and counts the number of lines by incrementing the line variable by 1, each time it reads the line.

split() function is used to split the each line string into a list. This split is stored in totalwords.

Next statement words = words + len(totalwords)  is used to find the number of words in the text file. When the lines are split in to a list then the length of each split is found by the len() function and added to the words variable in order to find the number of words in the text file.

Next, in order to find the number of characters, for loop is used. The loop moves through each word in the list totalwords and split each word in the totalwords list using split() method. This makes a list of each character in every word of the text file. This calculates the number of characters in each word. Each word split is added to the character and stored in character variable.

file_stats('created_equal.txt')  statement calls the file_stats() method and passes a file name of the text file created_equal.txt as an argument to this method. The last three print() statements display the number of lines, words and characters in the created_equal.txt text file.

The program along with its output is attached.

6 0
1 year ago
suppose that you have been given the task of writing an unloader - that is, a piece of software that can take the image of a pro
Brums [2.3K]
............;(&;&;$;!:$:!;$;8;$;$;;$;&8;$;$;$;$;$;$;$;$;$;
8 0
1 year ago
Ivan has five workbooks open. He has arranged these files in a specific grouping so he can view them at the same time. In order
Dafna1 [17]
Folder, Right? I'm sorry if this is not correct.
8 0
1 year ago
Other questions:
  • A circuit contains three resistors connected in parallel. The value of R1 is 2 K , the value or R2 is 6 K , and the value of R3
    5·1 answer
  • The piston engine uses the ________ to convert the reciprocating motion of the piston into rotary motion.
    13·1 answer
  • In which of the following situations may you pass on the right
    13·2 answers
  • Karen just finished typing an important memo that she needs to send to many people, including the president of the company. Kare
    15·2 answers
  • To keep from overwriting existing fields with your Lookup you can use the ____________ clause.
    14·2 answers
  • Fill in the blank; "As well as their traditional role of computing data, computers are also extensively used for..."
    14·1 answer
  • add is a method that accepts two int arguments and returns their sum. Two int variables, euroSales and asiaSales, have already b
    11·1 answer
  • You're the sole IT employee at your company, and you don't know how many users or computers are in your organization. Uh oh! Wha
    8·1 answer
  • In defining security implemention, what are the roles of the following committees. 1) gateway committee 2) project committee 3)
    8·1 answer
  • The geographic coordinate system is used to represent any location on Earth as a combination of latitude and longitude values. T
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!