Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Concepts of Programming Languages Please provide the full answers to question 2 & 3 (below)! 2. How many lexemes does the following Java code contain?
Concepts of Programming Languages 2. How many lexemes does the following Java code contain? 1. public class RepeatString t 2 public static void main(String args[]) Scanner input = new Scanner (System.in ); System.out.println("Enter a string: " String phrase-input.nextLine) System.out.print 1n ("Enter # times to repeat string: "); int repetitionsinput.nextInt) repeat (phrase, repetitions); 10. public static void repeat (String str, int reps) for (int i = 1;
Please provide the full answers to question 2 & 3 (below)!
2. How many lexemes does the following Java code contain?
1. public class RepeatString {
2. public static void main(String args[]) {
3. Scanner input = new Scanner(System.in);
4. System.out.println("Enter a string: ");
5. String phrase = input.nextLine();
6. System.out.println("Enter # times to repeat string: ");
7. int repetitions = input.nextInt();
8. repeat(phrase, repetitions);
9. }
10. public static void repeat(String str, int reps) {
11. for (int i = 1; i
12. System.out.println(i + ". Repeat:\t" + str);
13. }
14. } }
Give the number of lexemes on each line (using the line numbers shown) as well as the
total number of lexemes.
3. Problem 17 in Chapter 1 of Sebesta:
Some programming languages --- for example, Pascal --- have used the semicolon to
separate statements, while Java uses it to terminate statements. Which of these, in your
opinion, is most natural and least likely to result in syntax errors? Support your answers.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started