Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to fix the program so that it can execute the following statements example: PRINT PRINT (Print statement) error in the second statement 1.

I need to fix the program so that it can execute the following statements example: PRINT PRINT (Print statement) error in the second statement

1. w = "HOLA"

2. y = " MUNDO"

3. if 3 .gt. 2 then a = 2 .add. 1 .add. 3 .mul. 4

4. z = w .add. y

5. print z

6. print (like enter when we are executing code)

7. print(like enter when we are executing code)

8. if z .eq. "HOLA MUNDO" then print z

9. cc = 0

10. c2 = 9

11. c = 4

12. print (like enter when we are executing code)

13. print(like enter when we are executing code)

14. if c .eq. 4 then a = c .add. 3 .div. 3

15. n = 3.0 .add. 2 .mul. c

14. print "n = "

15. print n

16. print(like enter when we are executing code)

17. print(like enter when we are executing code)

18. a = 3 .mul. c .add. 2

19. print "a = "

20. print a

21. print(like enter when we are executing code)

22. print(like enter when we are executing code)

23. print "ENTER AN INTEGER NUMBER: "

24. read b

25. print(like enter when we are executing code)

26. print(like enter when we are executing code)

27. print "YOU ENTERED: "

28.print b

29. print(like enter when we are executing code)

30. print

31. print

32. if b .gt. 7 .and. b .le. 9 .or. b .eq. 8 then print "a = "

33. if b .gt. 7 .and. b .le. 9 .or. b .eq. 8 then print a

34. print(like enter when we are executing code)

35. print(like enter when we are executing code)

36. end.

EXAMPLEimage text in transcribed

#include

#include

#include

#include

using namespace std;

void keyword(int, char*, char*, char*, char*, char*, char*, char*, char*, char*, char*, char*);

void checkPrint(char*, char*,int);

void checkVariable(char*);

void checkNumber(char*);

void checkOperator();

void checkAdd();

void checkOperator2();

void checkOperator3();

int main()

{

char end[] = "END.", print[] = "PRINT", if_[] = "IF", read[] = "READ", eq[] = ".EQ.", add[] = ".ADD.", or_[] = ".OR.", and_[]=".AND.", xor_[]=".XOR.", then[] = "THEN";

char rem[]="REM";

char var[] = "abcdefghijklmnopqrstuvwxyz";

char num[] = "0123456789";

char input[100];

do

{

cout

cin.getline(input, 100);

int size = strlen(input);

//Para entrar Variable

if (*input == var[0] || *input == var[1] || *input == var[2] || *input == var[3] || *input == var[4] || *input == var[5] || *input == var[6] || *input == var[7] || *input == var[8] || *input == var[9] || *input == var[10] || *input

== var[11] || *input == var[12] || *input == var[13] || *input == var[14] || *input == var[15] || *input == var[16] || *input == var[17] || *input == var[18] || *input == var[19] || *input == var[20] || *input == var[21] || *input == var[22] || *input == var[23] || *input == var[24] || *input == var[25] || *input == var[26])

{

checkVariable(input);

}

//Para entrar Number

if (*input == num[0] || *input == num[1] || *input == num[2] || *input == num[3] || *input == num[4] || *input == num[5] || *input == num[6] || *input == num[7] || *input == num[8] || *input == num[9])

{

checkNumber(input);

}

//Para entrar REM

if (input[0] == rem[0] && input[1] == rem[1] && input[2] == rem[2])

{

cout

}

//Keywords

keyword(size, then, num, input, end, print, if_, read, add, eq, or_, var);

//.XOR.

if (xor_[0] == input[0] && xor_[1] == input[1] && xor_[2] == input[2] && xor_[3] == input[3] && xor_[4] == input[4])

{

cout

}

//Invalid Syntax

if (input[0] == '?' || input[0]=='=')

{

cout

}

cout

} while (1);

return 0;

}

//functions:

void keyword(int size, char* then, char* and_, char* input, char* end, char* print, char* if_, char* read, char* add, char* eq, char* or_, char* var)

{

for (int i = 0; i

{

input[i] = toupper(input[i]);

}

//Para entrar THEN

if (input[0] == then[0] && input[1] == then[1] && input[2] == then[2] && input[3] == then[3])

{

cout

}

//Para entrar .EQ.

if (eq[0] == input[0] && eq[1] == input[1] && eq[2] == input[2] && eq[3] == input[3])

{

checkOperator();

}

//Para entrar .OR.

if (or_[0] == input[0] && or_[1] == input[1] && or_[2] == input[2] && or_[3] == input[3])

{

checkOperator2();

}

//Para entrar .AND.

if (and_[0] == input[0] && and_[1] == input[1] && and_[2] == input[2] && and_[3] == input[3] && and_[4] == input[4])

{

checkOperator3();

}

//Para entral .ADD.

if (add[0] == input[0] && add[1] == input[1] && add[2] == input[2] && add[3] == input[3] && add[4] == input[4])

{

checkAdd();

}

//Para entrar END.

if (input[0] == end[0] && input[1] == end[1] && input[2] == end[2] && input[3] == end[3])

{

cout

}

//Para entrar IF

if (input[0] == if_[0] && input[1] == if_[1])

{

cout

}

//Para entrar PRINT

if (input[0] == print[0] && input[1] == print[1] && input[2] == print[2] && input[3] == print[3] && input[4] == print[4])

{

if (!(input[6] == *("\"") && input[size - 1] == *("\"")))

{

cout

}

else

{

checkPrint(input, print, size);

}

}

//Para entrar READ

if (input[0] == read[0] && input[1] == read[1] && input[2] == read[2] && input[3] == read[3])

{

cout

}

}

void checkOperator()

{

cout

}

void checkAdd()

{

cout

}

void checkOperator2()

{

cout

}

void checkOperator3()

{

cout

}

void checkPrint(char* input,char* print,int size)

{

if (input[6] == *("\"") && input[size - 1] == *("\""))

{

cout

}

else

{

cout

}

}

void checkVariable(char* input)

{

cout

}

void checkNumber(char* input)

{

int size = strlen(input);

int found=0;

for (int f = 0; f

{

if (input[f]=='.')

{

found = f;

}

}

if (input[found] == '.')

{

cout

}

else

{

cout

}

}

LAO C Programides (6)\Microsoft Visual Studio Shared Python37 64\python.exe True: LAO > READ a1 tex res Invalid Syntax: Invalid User Input File , line 1 if els, READ al LAO > PRINT PRINT Invalid Syntax: Double Print Error File , line 1 PRINT PRINT AAAAA LAO LAO C Programides (6)\Microsoft Visual Studio Shared Python37 64\python.exe True: LAO > READ a1 tex res Invalid Syntax: Invalid User Input File , line 1 if els, READ al LAO > PRINT PRINT Invalid Syntax: Double Print Error File , line 1 PRINT PRINT AAAAA LAO

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

Students also viewed these Databases questions

Question

Discuss the history of human resource management (HRM).

Answered: 1 week ago