C++ programming/Introduction to MatLab
THE PROJECT
This project requires you to find more Pythagorean Triples, or right triangles with all integer side lengths. The list of triples produced must be limited by prompting for and reading a maximum side length from the user. No side, a, b, or c, can be longer than the maximum side length provided by the user. The maximum side length obtained from the user must be validated as an integer value that is strictly greater than zero. Illegal maximum side lengths should be reported with appropriate error messages.
FINDING TRIPLES
After validating user input, your program script must call a separate function that counts and returns the number of triples found. As it finds triples, it must call a subfunction that prints that triple to the screen. After this search function returns the number that it found, the program script must print the number found.
EXCLUDING DUPLICATES
These are the same triangles that have had sides a and b flipped. Your solution must exclude these duplicates by making sure that the length of “Side A” is always strictly less than the length of “Side B”. Or stated another way, the values for each triple reported must be strictly increasing when reported in the order: Side A, Side B, Hypotenuse.
ANOTHER TYPE OF DUPLICATE
Your final task is to eliminate these similar duplicates of scale. This task is more tricky. The easiest way to handle it is to store all side lengths a and b in parallel arrays.
TEST
-1
-2.3
2.3
5
10
15
25
1000
***Please upvote or give a rating if the solution helped you***
Screenshot of the C++ code:-

Screenshot of two outputs:-


C++ code to copy:-
#include<iostream>
#include <math.h>
using namespace std;
//A subfunction that prints that triple to the screen
void print(int a,int b,int c){
cout<< "\n"<< a << " " << b << " "
<< c <<endl;
}
//A separate function that counts and returns the number of
triples found.
int count(int lim){
//The sides and the hypotenuse respectively
int a,b,c;
int count = 0;
//Two parallel arrays to store the sides
int a_arr[lim],b_arr[lim];
//To iterate through the arrays
int i,j = 0;
bool found = false;
cout<< " \n Pythagorean triples between 1 to " << lim << ":\n\n "<<endl;
for(a = 1; a<=lim ; a++){
for( b = 1; b<=lim ; b++){
for( c = 1; c<=lim ; c++){
if((a*a + b*b) == c*c )
{
for(i = 0;i<j;i++)
{
//This elimimates the duplicates
if((b_arr[i] == a && a_arr[i] == b)|| (a % a_arr[i] == 0
&& b % b_arr[i] == 0))
{
found = true;
break;
}
}
if(found == false){
a_arr[j] = a;
b_arr[j] = b;
count++;
print(a,b,c);
j++;
}
else{
found = false;
}
}
}
}
}
return count;
}
int main()
{
int max_i;
double maxi;
//Prompting for and reading a maximum side length from the user
into a double variable
cout<<"Enter maximum side length";
cin >> maxi;
//Validating input and reporting with appropriate error
messages.
if (maxi > 0 && (round(maxi) == maxi)){
max_i = (int)maxi;
cout << "\n\nTotal no of triples found " <<
count(max_i);
}
else{
//If input is negative
if(maxi < 0)
cout << "Side length cannot be negative"<<endl;
////If input is fractional
else if(round(maxi) != maxi)
cout << "Side length cannot be fractional"<<endl;
}
}
C++ programming/Introduction to MatLab THE PROJECT This project requires you to find more Pythagorean Triples, or...
C code. Write a program to find all the triangles with integer side lengths and a user specified perimeter. Perimeter is the sum of all the sides of the triangle. Integers a, b and c form a triangle if the sum of the lengths of any two sides is greater than the third side. Your program should find all the triples a, b and c where a + b + c is user specified perimeter value. Print each triple only...
Write the java program: A right triangle can have sides whose lengths are all integers. The set of three integer values for the length of the sides of a triangle is called a Pythagorean triple. The length of the three sides must satisfy the relationship that the sum of the squares of the sides is equal to the square of the hypotenuse. Write a Java application that prompts the user for an integer that represents the largest side value and...
Write the java program: A right triangle can have sides whose lengths are all integers. The set of three integer values for the length of the sides of a triangle is called a Pythagorean triple. The length of the three sides must satisfy the relationship that the sum of the squares of the sides is equal to the square of the hypotenuse. Write a Java application that prompts the user for an integer that represents the largest side value and...
This is programming project 1 chapter 9(Book ISBN:1292222824
(1-292-22282-4) Walter Savitch Problem Solving with C++: Global
Edition, 10/E)
Question Do Programming Project 7 in Chapter 7 using a dynamic
array. In this version of the problem, use dynamic arrays to store
the ditits in each large integer. Allow an arbitrary number of
digits instead of capping the number of digits at 20.
TER 7/ Arrays time. For example digit at a the integer 1234 could be stored in the array...
C++ Programming Programming Project Outcomes: Understand and use C++ functions for procedural abstraction and Functional Decomposition Develop some functions for generating numerical data from numerical inputs Understand and utilize file input and file output to perform computing tasks Requirements: 1. You should do a functional decomposition to identify the functions that you will use in the program. These should include reading and writing the files, tallying and showing statistics, etc. 2. The program should prompt the user...
PROGRAM DESCRIPTIONIn this project, you have to write a C++ program to keep track of grades of students using structures and files.You are provided a data file named student.dat. Open the file to view it. Keep a backup of this file all the time since you will be editing this file in the program and may lose the content.The file has multiple rows—each row represents a student. The data items are in order: last name, first name including any middle...
C++
Hey, I really need help with this lab. I don't understand the
function part at all. It'll be great way for me to understand. Than
you
Functions and loops: Write a program that will ask the user which type of triangle they would like to draw on the characters. The choices are screen with left-top-big left-bottom-big right-top-big right-bottom-big Get the user's choice, ask how big it should be, and then draw the shape. After each successful drawing, ask the...
CS 215 Program Design, Abstraction, and Problem Solving Programming Project #3 INTRODUCTION The goal of this programming project is to enable the student to practice designing a program that solves a problem using a class and a linked-list and developing a C++ program to implement the solution. PROJECT TASKS 1. Read the problem definition below and then analyze it before designing a solution. You will produce a document (external documentation) of this definition, analysis, and design. 2. Write a C++...
C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...
Help with programming in C++
Phase 1 is complete, please help with phase 2. Thank you.
Phase 1
You must design 3 algorithms, and provide
both a flow chart and pseudo code for the
algorithms.
Algorithm descriptions:
Given an integer parameter named current_number
and two constant global variables:
const int MIN_NUMBER = 1;
const int MAX_NUMBER = 8;
Create an algorithm named forward, that will
advance ONE value through a sequence of numbers 1,
2, 3 ... MAX_NUMBER. In...