Question

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);
  
}

Objectives To learn to code, compile and run a program containing SELECTION structures Assignment Write an interactive C++.pr

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

1 6 8 checkTriangle.cpp #include<iostream> 2 using namespace std; 3 4 int main() { 5 double a,b,c; 7 do{ 9 cout<<Enter side} } ...... check Triangle.cpp 29 E 30 else{ 31 cout<<scalene triangle<<endl; 32 33 34 if(a+b>c) { 35 6 if((ata)+(b*b)==(c*cX E C:\Users\shanmukha\Desktop\check Triangle.exe Enter side a:3 Enter side b:4 Enter side c:5 Entered sides are:a:3 6:4 c:5C:\Users\shanmukha\Desktop\checkTriangle.exe Invalid Triangle A triangle side cannot be negative or Zero Please enter again!!C:\Users\shanmukha\Desktop\check Triangle.exe Enter side a:2 Enter side b:2 Enter side c:4 Entered sides are:a:2 6:2 0:4 Type

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

IF YOU HAVE ANY PROBLEM REGARDING THE SOLUTION PLEASE COMMENT BELOW I WILL DEFINETLY HELP YOU

Add a comment
Know the answer?
Add Answer to:
PLEASE READ AND CODE IN BASIC C++ CODE. ALSO, PLEASE CODE USING THIS DO WHILE LOOP...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Your math professor asked you to determine whether triangles are equilateral, isosceles, or scalene triangles. You...

    Your math professor asked you to determine whether triangles are equilateral, isosceles, or scalene triangles. You need to write a MATLAB program that accepts the side lengths for sides A, B, and C of a triangle and compares the side lengths in order to determine if the triangle is equilateral, isosceles, or scalene. Each triangle will only be classified as a single type based on the definitions below: 1. An equilateral triangle is a triangle in which all three sides...

  • help im alittle lost my teacher posted all this its suppose to be in C++ language....

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

    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++ 17 please help!! A triangle can be of three types-one in which all the sides...

    c++ 17 please help!! A triangle can be of three types-one in which all the sides are equal, or one in which only two sides are equal, or one in which all the three sides are unequal. You are assigned to write a program that allows the user to enter the three sides of a triangle. The program should use three double variables to store the three sides of the triangle. The program should also be able to print the...

  • C code. Write a program to find all the triangles with integer side lengths and a...

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

  • C++ Can somebody help me with this 2 integer right triangles There are right-angled triangles (i.e.,...

    C++ Can somebody help me with this 2 integer right triangles There are right-angled triangles (i.e., triangles, for which the theorem of Pythagoras applies), whose side lengths are all integers are.  Write a program that finds all these triangles in the form of the lengths of their three sides and these three Output page lengths for each triangle found. This should only page lengths not greater than 500 are taken into account.  In addition, specify the number of...

  • Java Please - Design and implement a class Triangle. A constructor should accept the lengths of...

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

  • Use Python and only while loops For this part of the homework you will write code...

    Use Python and only while loops For this part of the homework you will write code to draw an isosceles right triangle. (A right triangle in which the height and base are the same size.) Your program should prompt the user for these inputs, in exactly this order: 1. The height of their triangle 2. The symbol the triangle will be outlined in 3. The symbol the triangle will be filled with For these inputs, you can assume the following:...

  • Using Visual Studio 2017 Create This Program Using C# implement source code Program 5: The concept...

    Using Visual Studio 2017 Create This Program Using C# implement source code Program 5: The concept of a 5-digit palindrome number is a 5-digit number that reads the same from left to right and from right to left. For example, 12121, 45454, and 14741 are valid 5-digit palindrome numbers. Design (pseudocode) and implement (source code) a program (name it FiveDigitPalindrom) that reads a 5-digit number from the user (as integer value, not string) and then mathematically (using division and remainder...

  • Complete the Rectangle Program Using the code given in rectangle.cpp, implement the functions that are called...

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

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT