Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

FOR JAVA PLEASE: SIMPLE CODE: 1 . 4 2 LAB: Input and formatted output: Right - facing arrow Given two input integers for an arrowhead

FOR JAVA PLEASE: SIMPLE CODE: 1.42 LAB: Input and formatted output: Right-facing arrow
Given two input integers for an arrowhead and arrow body, print a right-facing arrow.
Ex: If the input is: 01
the output is:
1
11
00000111
000001111
00000111
11
1import java.util.Scanner;
public class LabProgram {
public static void main(String[] args){
Scanner scnr = new Scanner(
System.in);
int baseChar;
int headChar;
/* Type your code here. */
}
}
I used the following code: import java.util.Scanner;
public class LabProgram {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
System.out.print("Enter the base character: ");
char baseChar = scanner.next().charAt(0);
System.out.print("Enter the head character: ");
char headChar = scanner.next().charAt(0);
System.out.println(""+ headChar);
System.out.println(""+ headChar + headChar);
for (int i =0; i 3; i++){
for (int j =0; j 5; j++){
System.out.print(baseChar);
}
if (i ==0|| i ==2){
System.out.println(headChar +""+ headChar +""+ headChar);
} else {
System.out.println(headChar +""+ headChar +""+ headChar +""+ headChar);
}
}
System.out.println(""+ headChar +""+ headChar);
System.out.println(""+ headChar);
scanner.close();
}
}
I received the following errors:LabProgram.java:8: error: cannot find symbol
char baseChar = scanner.next().charAt(0);
^
symbol: variable scanner
location: class LabProgram
LabProgram.java:11: error: cannot find symbol
char headChar = scanner.next().charAt(0);
^
symbol: variable scanner
location: class LabProgram
LabProgram.java:31: error: cannot find symbol
scanner.close();
^
symbol: variable scanner
location: class LabProgram
3 errors
Now I am ggetting the following: 1:Compare output
0/5
Output differs. See highlights below.
Special character legend
Input
01
Your output
1
11
0000011
000001
0000011
Expected output
1
11
00000111
000001111
00000111
11
1
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

Solve the equation using completing the square. 3x 2 + 9x = 7

Answered: 1 week ago