
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Use the attached C program front.c (compile it – see the instruction for using the c program,) and apply it to (sum + 47) / total to get the following tokens
- Next token is: 25 Next lexeme is (
- Next token is: 11 Next lexeme is sum
- Next token is: 21 Next lexeme is +
- Next token is: 10 Next lexeme is 47
- Next token is: 26 Next lexeme is )
- Next token is: 24 Next lexeme is /
- Next token is: 11 Next lexeme is total
- Next token is: -1 Next lexeme is EOF
front.c:
Expert Solution

arrow_forward
Step 1
Code:
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.StringTokenizer;
/**
*
* @author prmsh
*/
public class Lexical {
public static void main(String args[]) throws FileNotFoundException{
//reading file
Scanner input = new Scanner(new File("C:\\Users\\prmsh\\Documents\\NetBeansProjects\\Chegg\\src\\chegg\\Expression.txt"));
while(input.hasNextLine()) {
//reading next line
String line = input.nextLine();
//reading tokens by space
StringTokenizer strings = new StringTokenizer(line," ");
//reading more strings
while (strings.hasMoreElements()) {
//converting object to string
String token = strings.nextElement().toString();
switch(token) //switch case
{
case "(" :
System.out.println("Next token is: 25 Next lexeme is (");
break;
case ")" :
System.out.println("Next token is: 26 Next lexeme is )");
break;
case "=" :
System.out.println("Next token is: 20 Next lexeme is =");
break;
case "+" :
System.out.println("Next token is: 21 Next lexeme is +");
break;
case "-" :
System.out.println("Next token is: 22 Next lexeme is -");
break;
case "*" :
System.out.println("Next token is: 23 Next lexeme is *");
break;
case "/" :
System.out.println("Next token is: 24 Next lexeme is /");
break;
default :
System.out.println("Next token is: 11 Next lexeme is "+token);
}
}
//finally end of the String
System.out.println("Next token is: -1 Next lexeme is EOF");
}
}
}
Step by stepSolved in 2 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Implementing matrix addition is pretty simple; see the program below. However, the given addition function matrix_add_double() does not run at full speed. On the instructors computer, which has 16GB of RAM, the program below shows that the call to matrix_add_double takes 38571 ms, while another, better implementation achieves the same result in 3794.7ms, which is 10.2 times faster! Your job for this exercise is: • to explain what in the Operating System and/or CPU and/or other part of the system makes the implementation below go so slowly. • to fix the code to achieve full speed. Hint: There are two reasons why the code runs slowly. The one reason is related to how virtual addresses get translated to physical addresses, the other reasons is related to another effect in the hardware. Only the performance for the matrix_add_double function() counts for your exam results. You can leave the other parts of the code untouched, but you may also change them.…arrow_forwardIn C++: Given the following recursive definition seq(1) = seq(2) = 1 seq(n) = 2*seq(n-1) + 3*seq(n-2) implement the corresponding program and use it to calculate seq(5). How many invocations are made to the function seq when calculating seq(5)?arrow_forwardThe Dirtcheap Software Company is planning to produce an assembler for a computer with a 48-bit word. To keep costs down, the project manager, Dr. Scrooge, has decided to limit the length of allowed symbols so that each symbol can be stored in a single word. Scrooge has declared that symbols may consist only of letters, except the letter Q, which is forbidden (to demonstrate their concern for efficiency to the custo- mers). What is the maximum length of a symbol? Describe your encoding scheme.arrow_forward
- Define the following sequence recursively, giving two instructions in mathematical language.{14, 9, 4, -1, . . .}arrow_forwardI need a C program where the input is postorder. For example, if the input is postorder: x1 5.12 + x2 7.68 - * x3 / then the resulting output would be an inorder: (((x1+5.12)*(x2-7.68))/x3)arrow_forward1. Write a recursive definition for the set of bit strings that have m ones followed by n zeros for all positive integers m and n. Here are some of the strings in the set: 1111100, 10, 100, 11110. Here are some strings not in the set: 111001, 11, 0, 0111. Need detailed answer. Thank you!!!arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education