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++

Projectdecision statementsdirections read carefully and

Project: Decision Statements Directions (Read CAREFULLY and follow COMPLETELY): - Create the following programs in C++ that perform the purpose described and show the sample output (with user input where applicable). - I ...

Assignmentwhen writing c programs include comments in your

Assignment When writing C++ programs include comments in your code, make the program readable by indenting, use meaningful variable and function names, and produce meaningful output. This assignment will be to write a bm ...

Write a program that reads numbers from cin and then sums

Write a program that reads numbers from cin and then sums them, stopping when 0 has been entered. Construct three versions of this program, using the while ,do - while , and for loops. Add the following to your program: ...

Bankers algorithmimplement the bankers algorithm for

Banker's Algorithm Implement the Banker's algorithm for deadlock avoidance, that works on a given set of N processes and M resource types (N The input data and result is then displayed on the screen. You may use your pro ...

Cs 2410workshop make-up assignmentwrite a c program that

CS 2410 Workshop Make-Up Assignment Write a C++ program that will output to a file called output.txt EVERY 10 digit phone number from 713-000-0000 through 713-000-0998. These numbers MUST only contain an odd number of ev ...

Practice with pointers and dynamic memory

Practice with pointers and dynamic memory allocation Problem: Write a C++ program that will implement and test the four functions described below that use pointers and dynamic memory allocation. The Functions: You will w ...

Object-oriented programming assignmentintroduction -nbspa

Object-Oriented Programming Assignment Introduction -  "A logical matrix or (0, 1) matrix is a matrix with entries from the Boolean domain B = {0, 1}. Such a matrix can be used to represent a binary relation between a pa ...

Write a c program that calculates and prints the average of

Write a C program that calculates and prints the average of two or more salaries entered by the user. The program should first prompt the user to enter the number of salaries to process (make sure: at least 2 salaries mu ...

Intro to programming in c assignmentsince this is the last

Intro to Programming in C Assignment Since this is the last assignment, there will be no late submission. All programs must be electronically submitted by 5:00pm on Tuesday, December 2nd with NO EXCEPTIONS in order to re ...

Create your own unique while-end repetition structure you

Create your own unique While-End repetition structure. You decide the theme. You should provide both the pseudocode and the flowchart of your example. Be sure to provide an overview of what your repetition structure is d ...

  • 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

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro

Describe what you learned about the impact of economic

Describe what you learned about the impact of economic, social, and demographic trends affecting the US labor environmen