Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

man make multiply 3.14 57 If a wrong number of arguments or wrong types are supp

ID: 3589700 • Letter: M

Question

man make

multiply   3.14 57

If a wrong number of arguments or wrong types are supplied, it should display a message informing the user how to use the program correctly.
Your program must be made up of three modules, namely, main.cpp ( for handling the arguments ), product.cpp ( for calculating the product ), and print.cpp ( for printing out the product ). Check if each of the modules can be compiled properly by the command,

g++ -c program_name.cpp

To make your editing easier, open two terminals ( windows ), each of which should only occupy about 60% of your monitor screen; put one terminal on the upper left of the screen and the other on the lower right; use your upper left terminal to do the editing and the lower right one for compilation. You can switch from one terminal to another conveniently by clicking on the desired terminal with your mouse.

Finally, write a Makefile that contains all the compilation processes to generate the executable multiply. The Makefile should have a clean instruction so that when one executes,

make clean

the object files will be deleted. Try to experiment with the 'change directory' option discussed in a). Check your executable with sample inputs to ensure that everything works properly.

please include the command for compiling

a) Review of Makefile.
The UNIX make utility helps one organize projects and write programs in a modular and robust way. Modern software development is based on teamwork. By keeping track of dependency relationship among the parts of large, complex projects, make helps coordinate the efforts of many contributors. Study the usage of make by the command.

man make


b) Modular programming.
Write a program that asks for two numbers as arguments, multiplies them, and prints out the product and the two numbers. Call your executable, multiply; it operates like, for example,

multiply   3.14 57

If a wrong number of arguments or wrong types are supplied, it should display a message informing the user how to use the program correctly.
Your program must be made up of three modules, namely, main.cpp ( for handling the arguments ), product.cpp ( for calculating the product ), and print.cpp ( for printing out the product ). Check if each of the modules can be compiled properly by the command,

g++ -c program_name.cpp

To make your editing easier, open two terminals ( windows ), each of which should only occupy about 60% of your monitor screen; put one terminal on the upper left of the screen and the other on the lower right; use your upper left terminal to do the editing and the lower right one for compilation. You can switch from one terminal to another conveniently by clicking on the desired terminal with your mouse.

Finally, write a Makefile that contains all the compilation processes to generate the executable multiply. The Makefile should have a clean instruction so that when one executes,

make clean

the object files will be deleted. Try to experiment with the 'change directory' option discussed in a). Check your executable with sample inputs to ensure that everything works properly.

please include the command for compiling

Explanation / Answer

-----------------------------------------------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------------------------------------

// multiply.cpp file

# include "multiply.h"

double multiply(double x, double y)

{

return x*y;

}

--------------------------------------------------------------------------------------------------------------------------------------

// printvalue.cpp file

# include "printvalue.h"

void printvalue(double x)

{

cout<<"The product is"<<x;

}

---------------------------------------------------------------------------------------------------------------------

//main.cpp file

#include <iostream>
#include <cstdlib>

using namespace std;

int main(int argc, char** argv)

{
double x, y, z;
try{
x = argv[1];
y = argv[2]
}
catch(Exception e)
{
cout<<"Enter valid input";
}
  
z = multiply(x,y);
printvalue(z);
return 0;

}

-----------------------------------------------------------------------------------------------------------------

#Makefile

main: main.o multiply.o printvalue.o

$(CXX) $(CXXFLAGS) -o main main.o multiply.o printvalue.o

main.o: multiply.h printvalue.h

multiply.o: multiply.h

printvalue.o: printvalue.h

-----------------------------------------------------------------------------------------------------------------------------------

Steps to run the program.

1) Copy all files in same folder

2) Open cmd for that folder

3) Type following commands