Ask Question, Ask an Expert

+1-415-315-9853

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

Aims:

The main purpose of the assignment is to let you practice the following programming concepts and techniques:

  •  pointers;
  •  command line arguments;
  •  dynamic memory allocation;
  •  operations on strings.

General presentation:

Your program will accept an English description of a system of linear equations as command line arguments.

Practically, this English description will be stored in a le, say test.txt, and the program will be run with the command

a.out $(cat test.txt)

The English description of the system of linear equations is to be translated into a formal representation and solved.

The assignment does not require to build a parser: simple pattern matching can do the job.

The le helpers.c suggests a possible approach to get you started. Use it if you nd it useful, you might or might not include all or part of it in your implementation.

Detailed description:

Each equation will be described by a sentence that will be generated by the following context-free grammar. The nonterminal symbols of the grammar are:

SENTENCE
EXPRESSION1
EXPRESSION
PRODUCT1
PRODUCTS
PRODUCT
CONSTANTS
CONSTANT
VARIABLE

The start symbol is SENTENCE.

The production rules are:

SENTENCE --> EXPRESSION1 is equal to EXPRESSION.
SENTENCE --> EXPRESSION1 equals EXPRESSION.
EXPRESSION1 --> EXPRESSION1 plus EXPRESSION
EXPRESSION1 --> The result of adding PRODUCTS and PRODUCT
EXPRESSION1 --> The sum of PRODUCTS and PRODUCT
EXPRESSION1 --> PRODUCT1
EXPRESSION --> EXPRESSION plus EXPRESSION
EXPRESSION --> the result of adding PRODUCTS and PRODUCT
EXPRESSION --> the sum of PRODUCTS and PRODUCT
EXPRESSION --> PRODUCT
PRODUCTS --> PRODUCTS, PRODUCT
PRODUCTS --> PRODUCT
PRODUCT1 --> The result of multiplying CONSTANT by CONSTANT
PRODUCT1 --> The result of multiplying VARIABLE by CONSTANT
PRODUCT1 --> The result of multiplying CONSTANT by VARIABLE
PRODUCT1 --> The product of CONSTANTS and CONSTANT
PRODUCT1 --> The product of VARIABLE, CONSTANTS and CONSTANT
PRODUCT1 --> The product of VARIABLE and CONSTANT
PRODUCT1 --> The product of CONSTANTS, VARIABLE, CONSTANTS and CONSTANT
PRODUCT1 --> The product of CONSTANTS, VARIABLE and CONSTANT
PRODUCT1 --> The product of CONSTANTS and VARIABLE
PRODUCT --> the result of multiplying CONSTANT by CONSTANT
PRODUCT --> the result of multiplying VARIABLE by CONSTANT
PRODUCT --> the result of multiplying CONSTANT by VARIABLE
PRODUCT --> the product of CONSTANTS and CONSTANT
PRODUCT --> the product of VARIABLE, CONSTANTS and CONSTANT
PRODUCT --> the product of VARIABLE and CONSTANT
PRODUCT --> the product of CONSTANTS, VARIABLE, CONSTANTS and CONSTANT
PRODUCT --> the product of CONSTANTS, VARIABLE and CONSTANT
PRODUCT --> the product of CONSTANTS and VARIABLE
PRODUCT --> CONSTANT times CONSTANT
PRODUCT --> VARIABLE times CONSTANT
PRODUCT --> CONSTANT times VARIABLE
PRODUCT --> CONSTANT
PRODUCT --> VARIABLE
CONSTANTS --> CONSTANTS, CONSTANT
CONSTANTS --> CONSTANT
plus the production rules of the form
CONSTANT --> C_constant_of_type_int_or_float
VARIABLE --> C_variable

Hence the terminal symbols of the grammar are all lowercase words in the production rules, which includes C constants and variables.

An English equation is a sentence generated by the grammar, namely, any sequence of terminals that can be obtained from the grammar, starting with SENTENCE (the start symbol), applying the production rules, until nothing but terminals are obtained.

No assumption should be made on the number of English equations provided as input, nor on the length of an English equation, nor on the length of a variable.

The number of variables is assumed to be equal to the number of equations.

Your program should:

  • output the variables in the equations in lexicographic order;
  • output a formal representation of the English equations;
  • output whether or not there is a unique solution, and in case there is one, output it.

Sample outputs:

ex:

$ cat text_1.txt
The result of multiplying 2 by x plus y times 3 plus 5 times z is equal to 10.
The product of x and 3 plus the product of 7 and y plus z times 4 is equal to 3.
The product of 2 and y plus the result of multiplying z by 2 plus x equals 3.
$ a.out $(cat test_1.txt)
The variables are:
x y z
The equations are:
2.00 x + 3.00 y + 5.00 z = 10.00
3.00 x + 7.00 y + 4.00 z = 3.00
1.00 x + 2.00 y + 2.00 z = 3.00
The system of equations has a unique solution:
x = 3.00
y = -2.00
z = 2.00

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M91986

Have any Question? 


Related Questions in C/C++

C program codeoverviewfor this assignment write a program

C++ program code Overview For this assignment, write a program that will simulate a single game of Craps. Craps is a game of chance where a player (the shooter) will roll 2 six-sided dice. The sum of the die will determi ...

Text exercise 413 gas mileagebulldrivers are concerned with

Text Exercise 4.13 (Gas Mileage) • Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several trips by recording miles driven and gallons used for each trip. Develop a C++ ...

A write an array implementation of self-adjusting lists in

a. Write an array implementation of self-adjusting lists. In a self-adjusting list, all insertions are performed at the front. A self-adjusting list adds a find operation, and when an element is accessed by a find, it is ...

Write a program that calculates mileage reimbursement for a

Write a program that calculates mileage reimbursement for a salesperson at a rate of $0.35 per mile. Your program should interact with the user in this manner: MILEAGE REIMBURSEMENT CALCULATOR Enter beginning odometer re ...

Write code to create the generator submit your source code

Write code to create the generator. Submit your source code as well as a description of how I could run the program, sample screenshots of the program in action, and the various changes that could be produced through you ...

C program assignmentaccording to C Program Assignment According to

C Program Assignment According to http://en.wikipedia.org/wiki/Great-circle_distance, the great circle distance based on two coordinates in nautical miles is given by: d = r * Δσ where r is the radius of the earth and Δσ ...

Question 1you are facing the following problem you are

Question 1 You are facing the following problem: You are given a robot and your task is to "guide" the robot through a 2-dimensional maze such that the robot can reach a desired goal state. Assume that the maze is define ...

Computer scienceprogram-write a c program that willpresent

Computer Science Program- Write a C++ program that will: Present the user with a menu of choices: 1. Random number 2. String 3. Type Casting 4. Integer Math Then, in an if-else if structure (or switch) write the code for ...

Q 1 write a c program to declare two integer one float

Q. 1 Write a C++ program to declare two integer , one float variables and assign 10, 15, and 12.6 to them respectively. It then prints these values on the screen. Q. 2 Write a C++ program to prompt the user to input her/ ...

1 requirementsin this assignment you can unleash your

1. REQUIREMENTS In this assignment, you can unleash your imaginations and use OpenGL with C/C++ programming to produce a scene(s) that represents what you envision could possibly be seen under the sea. Please note that a ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

A cola-dispensing machine is set to dispense 9 ounces of

A cola-dispensing machine is set to dispense 9 ounces of cola per cup, with a standard deviation of 1.0 ounce. The manuf

What is marketingbullwhat is marketing think back to your

What is Marketing? • "What is marketing"? Think back to your impressions before you started this class versus how you

Question -your client david smith runs a small it

QUESTION - Your client, David Smith runs a small IT consulting business specialising in computer software and techno

Inspection of a random sample of 22 aircraft showed that 15

Inspection of a random sample of 22 aircraft showed that 15 needed repairs to fix a wiring problem that might compromise

Effective hrmquestionhow can an effective hrm system help

Effective HRM Question How can an effective HRM system help facilitate the achievement of an organization's strate