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

Write a c program that requests the name of any cartoon

Write a C program that requests the name of any cartoon character from the user, then does the following with that name (use printf for each): a. Displays it enclosed in double quotes. b. Displays it in a field 24 charac ...

1 create a c visual studio console application with the

1. Create a C++ visual studio console application with the name Project2. (As usual, to make the grader happy, it is critical that your project as well as your zip file contain your name and the exercise or project numbe ...

1 we know that from ece 109 to calculate the

1. We know that from ECE 109, to calculate the equivalent resistance of a network of resistors in series in parallel are given by: Write a C++ program that asks the user to input values for resistors (as many as they wou ...

Assessment taskthis coursework will allow you to

Assessment Task: This coursework will allow you to investigate some of the issues involved in writing threaded programs. You are to write a series of simple programs in C/C++ that will run under Linux, to illustrate how ...

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

Assignmentobjectivespractice reading characters from a

Assignment Objectives Practice reading characters from a file Practice using command line input Practice using command-line redirection of files Practice implementing a double transposition ciphering algorithm Summary In ...

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

1 write a c program that allows the user to create a test

1. Write a C++ program that allows the user to create a test bank of questions 2. The program should first ask the user how many questions he or she wishes to create. 3- The user should now be prompted for all informatio ...

Intro to programming in c programming assignmentassignment

Intro to Programming in C Programming Assignment Assignment purpose: User defined functions, pointers, Menu driven program A Company needs to create software for their new line of phone applications. Customers will have ...

1 three employees in a company are up special pay increase

1. Three employees in a company are up special pay increase. You are given a file, with the following data: Miller Andrew 65789.87 5 Green Sheila 75892.56 6 Sethi Amit 74900.50 6.1 Each input line consists of an employee ...

  • 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