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
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_2

Step: 3

blur-text-image_3

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

=+2. What is a common problem with self-report tests?

Answered: 1 week ago

Question

1. Describe the factors that lead to productive conflict

Answered: 1 week ago