Question

In: Computer Science

System.out.println('|'+nTimes(".",n-i-1))+ nTimes("/\\",(i+1))+nTimes(".",((n-i-1)*2))+ nTimes("/\\",(i+1))+nTimes(".",(n-i-1))+'|'); this code above is incorrect can somebody please explain why? thank you. if...

System.out.println('|'+nTimes(".",n-i-1))+
nTimes("/\\",(i+1))+nTimes(".",((n-i-1)*2))+ nTimes("/\\",(i+1))+nTimes(".",(n-i-1))+'|');


this code above is incorrect can somebody please explain why? thank you. if you are confused the full java code is below

public class RocketDraw{
public final static in n=3;
public static void main(String[] args){in i;
for(i=o;i<n*2-1;i++)
System.out.println(nTimes("",(n*2-i-1))+
nTimes("/",(i+1))+"**"+nTimes("\\",(i+1)));
System.out.println('+'+nTimes("*=",(n*2))+'+');
for(i=o;i<n;i++)
System.out.println('I'+nTimes(".",(n-i-1))+
nTimes("/\\",(i+1))+nTimes(".",((n-i-1)*2))+
nTimes("/\\",(i+1))+nTimes(".",(n-i-1))+'|');
for(i=0;i<n;i++)
System.out.println('|'+nTimes(".",i)+nTimes("\\/",
(n-i))+nTimes(".",(i*2))+nTimes ("\\/",(n-i))+
nTimes(".",i)+'|');
System.out.println('+'+nTimes("*=",(n*2))+'+');
for(i=0;i<n;i++)
System.out.println('|'+nTimes(".",i)+nTimes("\\/",(n-i))+ nTimes(nTimes(".",(i*2))+nTimes("\\/",(n-i))+nTimes(".",i)+'|'));
for(i=0;i<n;i++)
System.out.println('|'+nTimes(".",n-i-1))+
nTimes("/\\",(i+1))+nTimes(".",((n-i-1)*2))+ nTimes("/\\",(i+1))+nTimes(".",(n-i-1))+'|');
System.out.println('+'+nTimes("*=",(n*2))+'+');
for(i=0; i<n*2-1; i++)
System.out.println(nTimes("",(n*2-i-1))+
nTimes("/",(i+1))+"**"+nTimes("\\",(i+1)));
}
public static String nTimes(String s,int n)
{ String res="";for(int i=0; i<n; i++){res+=s;}
return res;}}


Solutions

Expert Solution

public class RocketDraw {
  public final static int n = 3;
  public static void main(String[] args) { 
      int i;
    for (i = 0; i < n * 2 - 1; i++)
        System.out.println(nTimes("", (n * 2 - i - 1)) + nTimes("/", (i + 1)) + "**" + nTimes("\\", (i + 1)));
    System.out.println('+' + nTimes("*=", (n * 2)) + '+');
    for (i = 0; i < n; i++)
        System.out.println('I' + nTimes(".", (n - i - 1)) + nTimes("/\\", (i + 1)) + nTimes(".", ((n - i - 1) * 2)) + nTimes("/\\", (i + 1)) + nTimes(".", (n - i - 1)) + '|');
    for (i = 0; i < n; i++)
        System.out.println('|' + nTimes(".", i) + nTimes("\\/", (n - i)) + nTimes(".", (i * 2)) + nTimes("\\/", (n - i)) + nTimes(".", i) + '|');
    System.out.println('+' + nTimes("*=", (n * 2)) + '+');
    for (i = 0; i < n; i++)
        System.out.println('|' + nTimes(".", i) + nTimes("\\/", (n - i)) + nTimes(".", (i * 2)) + nTimes("\\/", (n - i)) + nTimes(".", i) + '|');
    for (i = 0; i < n; i++)
        System.out.println('|' + nTimes(".", n - i - 1) + nTimes("/\\", (i + 1)) + nTimes(".", ((n - i - 1) * 2)) + nTimes("/\\", (i + 1)) + nTimes(".", (n - i - 1)) + '|');
    System.out.println('+' + nTimes("*=", (n * 2)) + '+');
    for (i = 0; i < n * 2 - 1; i++)
        System.out.println(nTimes("", (n * 2 - i - 1)) + nTimes("/", (i + 1)) + "**" + nTimes("\\", (i + 1)));
  }
  public static String nTimes(String s, int n) {
    String res = "";
    for (int i = 0; i < n; i++) {
      res += s;
    }
    return res;
  }
}

Explanation


-> There was an extra closing bracket

-> There was one extra call accidentally

Please up vote


Related Solutions

Please I can get a flowchart and a pseudocode for this java code. Thank you //import...
Please I can get a flowchart and a pseudocode for this java code. Thank you //import the required classes import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BirthdayReminder {       public static void main(String[] args) throws IOException {        // declare the required variables String sName = null; String names[] = new String[10]; String birthDates[] = new String[10]; int count = 0; boolean flag = false; // to read values from the console BufferedReader dataIn = new BufferedReader(new...
Question: Can I get the code in Java for this assignment to compare? Please and thank you....
Question: Can I get the code in Java for this assignment to compare? Please and thank you. Can I get the code in Java for this assignment to compare? Please and thank you. Description Write a Java program to read data from a text file (file name given on command line), process the text file by performing the following: Print the total number of words in the file. Print the total number of unique words (case sensitive) in the file. Print...
Please can I get a flowchart and pseudocode for this java code. Thank you. TestScore.java import...
Please can I get a flowchart and pseudocode for this java code. Thank you. TestScore.java import java.util.Scanner; ;//import Scanner to take input from user public class TestScore {    @SuppressWarnings("resource")    public static void main(String[] args) throws ScoreException {//main method may throw Score exception        int [] arr = new int [5]; //creating an integer array for student id        arr[0] = 20025; //assigning id for each student        arr[1] = 20026;        arr[2] = 20027;...
Please can I kindly get a flowchart for this java code. Thank you. //import the required...
Please can I kindly get a flowchart for this java code. Thank you. //import the required classes import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BirthdayReminder {       public static void main(String[] args) throws IOException {        // declare the required variables String sName = null; String names[] = new String[10]; String birthDates[] = new String[10]; int count = 0; boolean flag = false; // to read values from the console BufferedReader dataIn = new BufferedReader(new InputStreamReader( System.in));...
Can someone please explain these problems, I don't understand, please and thank you!! The patients in...
Can someone please explain these problems, I don't understand, please and thank you!! The patients in the Digoxin trial dataset can be considered a population of people suffering from heart failure. These patients were examined before the drug trial began, and their heart rate and blood pressure were recorded. The mean and standard deviation of the variables are listed below. Each variable follows a normal distribution. Heart rate (beats/min)                          μ = 78.8            σ = 12.66 Systolic blood pressure (mmHg)             μ...
Please explain to me the answers so that I can understand the concept. Thank you! You...
Please explain to me the answers so that I can understand the concept. Thank you! You must evaluate a proposal to buy a new milling machine. The purchase price of the milling machine, including shipping and installation costs, is $126,000, and the equipment will be fully depreciated at the time of purchase. The machine would be sold after 3 years for $85,000. The machine would require a $3,500 increase in net operating working capital (increased inventory less increased accounts payable)....
Guys can somebody please explain to me what is taxonomy? Like I am completely lost in...
Guys can somebody please explain to me what is taxonomy? Like I am completely lost in what all of it means, I don’t even understand when people talk about Metazoan animals and etc... Like every word is confusing and basically I am a mess, when It comes to this topic... Can somebody please help clear this up in a very clear and descriptive way? Thank you!!!!!
Hi, could you please provide a detailed explanation.. Thank you! Q1 (i) Explain how you can...
Hi, could you please provide a detailed explanation.. Thank you! Q1 (i) Explain how you can use Newton’s version of Kepler’s third law to measure mass of the Sun. (ii) Suppose a satellite is in ‘low Earth orbit’. Will that satellite remain in orbit forever, or will it eventually fall to the ground? Please explain your answer. Q2 A small black hole with mass equal to Earth’s mass hits the Sun, and eventually settles down in the core. Briefly explain...
Can you please show both in RStudio code? Thank You Airports: The temperature is recorded at...
Can you please show both in RStudio code? Thank You Airports: The temperature is recorded at 60 airports in a region. The average temperature is 68 degrees Fahrenheit with a standard deviation of 5 degrees. The last known average temperature from all airports is 67 degrees Fahrenheit.   Is the recorded temperature at the 60 airports different from the average temperature at all airports? Answer by determining statistical significance using the test statistic, degrees of freedom, and p-value. Answer substantive significance...
Somebody please explain, with examples, to me the notions of 1) Independance 2) Continuity 3) Monotonicity...
Somebody please explain, with examples, to me the notions of 1) Independance 2) Continuity 3) Monotonicity In Choice Under Uncertainty concept of Microeconomic Theory. I want to know how can one event/lottery satisfy 1 and not 2 (contin but not indep and monotonicity) or (monoton but not indep and cont), satisfy all, and neither.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT