Question: CONVERT TO C PROGRAMMING import java.util.*; import java.lang.*; import java.text.*; public class Prog2 { public static void main(String[] args) { Scanner sc= new Scanner(System.in); double

CONVERT TO C PROGRAMMING

import java.util.*;

import java.lang.*;

import java.text.*;

public class Prog2

{

public static void main(String[] args)

{

Scanner sc= new Scanner(System.in);

double p=200; //Load = 200 lbs

final double e = 30000000; //E=30*10^6lb/in

final double pi = 3.14;

NumberFormat numFormat = new DecimalFormat();

numFormat = new DecimalFormat("0.####E0");

double length;

System.out.println("Enter length of beam L :");

while(true)

{

length = sc.nextDouble();

if(length >= 16 && length <= 24)

break;

else

System.out.println("Length should be between 16 and 24. Re-Enter :");

}

int choice;

do

{

char ch;

System.out.println("Enter type of cross section :");

System.out.println("R ===> rectangular cross section");

System.out.println("T ===> triangular cross section");

System.out.println("C ===> circular cross section");

ch=sc.next().charAt(0);

double i=0,b,h,r;

switch(ch)

{

case 'R':

case 'r':

System.out.println("Enter base :");

b=sc.nextDouble();

System.out.println("Enter height :");

h=sc.nextDouble();

i= (b* Math.pow(h,3))/12;

break;

case 't':

case 'T':

System.out.println("Enter base :");

b=sc.nextDouble();

System.out.println("Enter height :");

h=sc.nextDouble();

i= (b* Math.pow(h,3))/36;

break;

case 'c':

case 'C':

System.out.println("Enter Radius :");

r=sc.nextDouble();

i=pi* Math.pow(r,4)/4;

break;

default:

System.out.println("Invalid Input");

}

double def = (p * Math.pow(length,3))/(3*e*i);

System.out.print("Deflection : ");

System.out.println(numFormat.format(def));

System.out.println(" Do you want to continue : 1. Yes 2.No");

choice = sc.nextInt();

}

while(choice == 1);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!