Ask C/C++ Expert


Home >> C/C++

UNIX AND C PROGRAMMING ASSIGNMENT QUESTIONS -

ATTEMPT ALL QUESTIONS.

Question 1 -

Write a C function (not a whole program) called calcPrices that will calculate final prices in a fishing/camping store.

Your colleagues have written several functions for applying discounts to a single product. They'd like your function to be able to call any one of their functions for each product. Your function must also ensure that the price remains positive. It should disregard any discounts that would make the price zero or negative.

Your function must return nothing, and accept the following parameters:

  • nCategories - The number of categories of products.
  • averageDiscount - The average discount applied to all products across all categories (as a pointer, for export purposes).
  • discountCalc - A pointer to one of your colleagues' discounting functions.

All of their functions takes a pointer to a float, representing a price. The function updates (reduces) the value stored at that location, or leaves it alone. The function returns nothing.

Each product category contains a number of different types of products. Categories are identified by an integer index, between zero and nCategories minus one. Within each category, products are also identified by an integer index, starting at zero. Your function must step through each product in each category, setting the new price. Your function should also calculate the average discount.

You will need to use three more functions which are provided for you. ie you do not need to write these:

  • To retrieve the number of different types of products in a category: int getNProducts(int category);
  • To retrieve the original product price: float getPrice(int category, int product);
  • To set the new price: void setPrice(int category, int product, float newPrice);

Question 2 -

NASA is designing a new space probe to search for life on other planets. The probe will be sent to a given planet. It will orbit the planet, map the surface and take sensor readings. The probe will look for promising locations on the surface for further exploration.

Your job is to design the software to analyse the probe's measurements. The probe will divide the planetary surface into a rectangular grid (excluding the polar regions).

The non-negative grid coordinates x and y will identify each grid square. The probe will take one set of readings in each grid square. Speci?cally, it will record:

  • temperature (oC),
  • wind speed (km/h),
  • oxygen concentration (%), and
  • volcanic activity (yes/no).

For each set of readings (i.e. for each grid square), your software must compute a "life rating". For the planet/grid as a whole, it must also compute an "exploration risk" (an indicator of the danger faced by further, surface exploration).

If there is no volcanic activity in a given grid square, the life rating is as follows:

life rating = (temperature x oxygen concentration)/wind speed

With volcanic activity, life rating is calculated the same way, but then divided by 3.5. For each grid square containing volcanic activity, exploration risk goes up by 1.

Write a C function (not a whole program) to do the following:

1. Retrieve the sensor readings from the probe, using the getReadings() function.

2. Calculate the life rating and exploration risk, as described above.

3. Report each life rating by calling another function (through a given function pointer).

4. Report the exploration risk (via an int* parameter).

The getReadings() function is declared as follows: void getReadings(int x, int y, double* temp, double* windSpeed, double* oxygen, int* volcanism);

Your function should return void and take four parameters:

  • width - an int, the width of the grid (0 ≤ x < width).
  • height - an int, the height of the grid (0 ≤ y < height).
  • explorationRisk - a pointer to an int.
  • reportFunc - a pointer to a function used to report the life rating. The function takes two ints (grid coordinates) and a double (the life rating), and returns void.

Question 3 -

A private investigator has asked you to help develop software to analyse fingerprint data. The software will have access to the left and right index fingerprints for a group of people, and also a collection of unidentified prints. The investigator wishes to know how many of the as-yet unidentified prints "possibly" or "definitely" belong to known individuals.

Each person is identified by an integer ID, ranging from zero to the number of people minus one. Each unidentified print is also identified by an integer ID, in the same fashion.

The left and right fingerprint data for each person is stored in a highly-reduced / compressed form - a "template". Each template takes only 64 bits to store.

Write a C function (not a whole program) called countMatches to do the following:

1. Retrieve each person's template fingerprints using the getTemplates function, which is declared as follows: void getTemplates(int person, double* left, double* right);

If getTemplates() places -1 in both *left and *right, no template fingerprint exists for that person. Such people cannot be tested, of course. For efficiency purposes, your function should skip over them.

2. If template fingerprints have been recorded for a given person, test them against each unidentified fingerprint. Your function will be supplied with a callback (function pointer) parameter for this purpose.

3. Report the total number of "possible" and "definite" fingerprint matches, via two int* (pass-by-reference) parameters.

Your function should return void, and take five (5) parameters:

  • nPeople - an int, the number of people in the database;
  • nPrints - an int, the number of unidentified fingerprints;
  • nPossible - a pointer to an int, the number of "possible" fingerprint matches;
  • nDefinite - a pointer to an int, the number of "definite" fingerprint matches; and
  • check - a pointer to a function used to check fingerprint templates against unidentified prints.

The callback function takes an int - the ID of the unidentified print - and two doubles-the left and right templates. It returns one of three int values: 0, indicating no match; 1, indicating a possible match; or 2, indicating a definite match.

Do not attempt to write the getTemplates() function or the callback function yourself. (These have already been implemented.)

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M92757748
  • Price:- $85

Guranteed 48 Hours Delivery, In Price:- $85

Have any Question?


Related Questions in C/C++

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

  • 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

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As