Answered step by step
Verified Expert Solution
Link Copied!

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
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.
image text in transcribed
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;

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

=+3 In what ways can an MNE improve or change its approach to IHRM?

Answered: 1 week ago