PLEASE READ AND CODE IN BASIC C++ CODE. ALSO, PLEASE CODE USING THIS DO WHILE LOOP AND FORMAT:
#include <iostream>
using namespace std;
int main() {
//variables here
do {
// program here
}while (true);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CODE TO COPY
#include<iostream>
using namespace std;
int main(){
double a,b,c;
do{
cout<<"Enter side a:";
cin>>a;
cout<<"Enter side b:";
cin>>b;
cout<<"Enter side c:";
cin>>c;
cout<<endl<<"Entered
sides are:";
cout<<"a:"<<a<<"
b:"<<b<<" c:"<<c<<endl;
if(a<=0 || b<=0 ||
c<=0){
cout<<"Invalid Triangle"<<endl;
cout<<"A
triangle Side cannot be negative or Zero Please enter
again!!"<<endl;
}
else{
cout<<"Type Of Triangle: ";
if(a==b
&& b==c && c==a){
cout<<"equilateral
triangle"<<endl;
}
else if(a==b ||
b==c || c==a){
cout<<"isosceles
triangle"<<endl;
}
else{
cout<<"scalene
triangle"<<endl;
}
if(a+b>c){
if((a*a)+(b*b)==(c*c)){
cout<<"The triangle
entered is a right triangle"<<endl;
}
else{
cout<<"Entered triangle
is not a right triangle"<<endl;
}
}
else
if(a+c>b){
if((a*a)+(c*c)==(b*b)){
cout<<"The triangle
entered is a right triangle"<<endl;
}
else{
cout<<"Entered triangle
is not a right triangle"<<endl;
}
}
else
if(b+c>a){
if((c*c)+(b*b)==(a*a)){
cout<<"The triangle
entered is a right triangle"<<endl;
}
else{
cout<<"Entered triangle
is not a right triangle"<<endl;
}
}else{
cout<<"Invalid
Triangle"<<endl;
cout<<"Third side of a triangle is not
greater than the two sides, hence a triangle cannot be
formed"<<endl;
}
}
cout<<endl<<"*************************************"<<endl;
cout<<endl;
}while(true);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
EXPLANATION
#include<iostream>
using namespace std;
int main(){
double a,b,c; //declaring variables for sides of
triangle
do{
cout<<"Enter side a:";
//printing statement
cin>>a; // taking input for
side a
cout<<"Enter side b:";
//printing statement
cin>>b;
cout<<"Enter side c:";
//printing statement
cin>>c;
cout<<endl<<"Entered
sides are:"; //printing statement where endl refers to next
line
cout<<"a:"<<a<<"
b:"<<b<<" c:"<<c<<endl;
if(a<=0 || b<=0 || c<=0){
//checking whether any side is less than 0
cout<<"Invalid Triangle"<<endl; //printing
statement
cout<<"A
triangle Side cannot be negative or Zero Please enter
again!!"<<endl; //printing statement
}
else{ //if no side is
less than 0 check other conditions
cout<<"Type Of Triangle: "; //printing statement
if(a==b
&& b==c && c==a){ // if all sides are equal then
..
cout<<"equilateral triangle"<<endl;
// ..printing statement where endl refers to next line
}
else if(a==b ||
b==c || c==a){ //if all sides are not equal and two sides are
equal
cout<<"isosceles triangle"<<endl; //
.. printing statement where endl refers to next line
}
else{ // if no
two sides are equal
cout<<"scalene
triangle"<<endl;//printing statement where endl refers to
next line
}
//checking if
sum of a, b is greater than c
if(a+b>c){
//checking if
the triangle sides form a right triangle
//since third
side must be greater than other two sides in triangle we assume c
as greater side
if((a*a)+(b*b)==(c*c)){
cout<<"The triangle
entered is a right triangle"<<endl; //printing statement
where endl refers to next line
}
else{
cout<<"Entered triangle
is not a right triangle"<<endl; //printing statement where
endl refers to next line
}
}
//checking if
sum of a, c is greater than b
else
if(a+c>b){
//checking if the triangle sides form a right
triangle
if((a*a)+(c*c)==(b*b)){
cout<<"The triangle
entered is a right triangle"<<endl; //printing statement
where endl refers to next line
}
else{
cout<<"Entered triangle
is not a right triangle"<<endl; //printing statement where
endl refers to next line
}
}
else
if(b+c>a){
//checking if the triangle sides form a right
triangle
if((c*c)+(b*b)==(a*a)){
cout<<"The triangle
entered is a right triangle"<<endl; //printing statement
where endl refers to next line
}
else{
cout<<"Entered triangle
is not a right triangle"<<endl; //printing statement where
endl refers to next line
}
}else{ // if two
sides sum is not greater than 3rd side show the below
statements
cout<<"Invalid Triangle"<<endl;
//printing statement where endl refers to next line
cout<<"Third side of a triangle is not
greater than the two sides, hence a triangle cannot be
formed"<<endl;
}
}
cout<<endl<<"*************************************"<<endl;
//printing line
cout<<endl; //going to next
line
}while(true);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
IF YOU HAVE ANY PROBLEM REGARDING THE SOLUTION PLEASE COMMENT BELOW I WILL DEFINETLY HELP YOU
PLEASE READ AND CODE IN BASIC C++ CODE. ALSO, PLEASE CODE USING THIS DO WHILE LOOP...
help im alittle lost my teacher posted all this its suppose to be in C++ language. can yoh leave comments ans type the code thank you Write a C++ program that accepts the lengths of three sides (a,b,c) of a triangle as input from the user Validate the user input, so that sides a, b, c can only be POSITIVE. The program output should indicate whether or not the triangle is an Equilateral Triangle, a Right Triangle, Isosceles which is...
Welcome to the Triangles program Enter length 1: 3 Enter length 2: 5 Enter length 3: 5 Enter the base: 5 Enter the height: 8 --------------------- The triangle is Isosceles since it has two equal length sides. Isosceles triangle also has two equal angles The area is: 20 The permimeter is: 13 Continue? (y/n): y Enter length 1: 10 Enter length 2: 10 Enter length 3: 10 Enter the base: 10 Enter the height: 7 --------------------- The triangle is Equilateral...
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...
The purpose of this assignment is to get experience with an array, do while loop and read and write file operations. Your goal is to create a program that reads the exam.txt file with 10 scores. After that, the user can select from a 4 choice menu that handles the user’s choices as described in the details below. The program should display the menu until the user selects the menu option quit. The project requirements: It is an important part...
Java Please - Design and implement a class Triangle. A constructor should accept the lengths of a triangle’s 3 sides (as integers) and verify that the sum of any 2 sides is greater than the 3rd(i.e., that the 3 sides satisfy the triangle inequality). The constructor should mark the triangle as valid or invalid; do not throw an exception. Provide get and set methods for the 3 sides, and recheck for validity in the set methods. Provide a toString method...
Complete the Rectangle Program Using the code given in rectangle.cpp, implement the functions that are called in the main function to complete the program. You must not change any of the existing code in the file. You can only add functions and comments to the code. Here’s a sample run of how the program should behave: Enter rectangle length: -1 ← invalid value, ask user to re-enter Enter rectangle length: -2 ← invalid value Enter rectangle length: 0 ← invalid...
17. (2 points) C++ Using a while loop, write the code statements to sum 10 integers entered by a user. Display the sum. Hint: Be sure to declare, initialize, and use appropriate variables to count the repetitions and accumulate the sum.
Must be java code Project 2b: CalculatePerimeter You are to write code for the application CalculatePerimeter where the computer calculates and displays the perimeter of a triangle, provided the three double values entered from keyboard input represent a triangle. If they don't, the computer should display the fact that (at least, in the case of non-positive input) one of the values does not form a valid triangle What makes a valid triangle? All sides must be positive and the sum...
in c++ language 1.Re-write the following for loop statement by using a while loop statement: int sum = 0; for(int i=0;i<=1000;i++){ sum+=i; } 1 (b). Following is the main () function of a program. The program asks a user to enter 150 integers and print the largest integer user entered. int main() { int score, highest; //missing portion of the program return 0; } 1(c). Find the missing portion of the following code, so the...
programming in Microsoft visual studio. Write a C++ program for the following algorithm. Compile, run, and verify the result by choosing some test data. Prompt user to write X1 value in double Read X1 Prompt user to write X2 value in double Read X2 Prompt user to write Y1 value in double Read Y1 Prompt user to write Y2 value in double Read Y2 Compute the lengths of the two sides of the right triangle generated by the two points...