Computer Science, asked by arpitakundu560, 26 days ago

Using the switch statement, write a menu-driven program to
perform the following operations :
0 To print the value of z where z = (x3 +0.5x)/y where
x ranges from -1 to 10 with an increment of 2 and y
remains constant as 5.5.
To print-the Floyd's Triangle with N rows.
ma​

Answers

Answered by Anonymous
12

\huge\mathfrak{Answer}

import java. util. * ;

class Pattern23

{

static void main ()

{

Scanner sc= new Scanner ( System.in ) ;

System.out.println( " Enter your choice ( whether 1 or 2 ) : " ) ;

int ch = sc.nextInt( ) ;

switch( ch )

{

case 1 :

double y = 5.5 , z ;

for ( int i = - 1 ; i < = 10 ; i +=2 )

{

z = ( ( x × x × x ) + 0.5 x ) / y

System.out.println ( z ) ;

}

break ;

case 2 :

System.out.println( " Enter the number of rows : " ) ;

int n = sc. nextInt( ) ;

int a = 1 ;

for ( int i = 1 ; i < = n ; i ++ )

{

for ( int j = 1 ; j < = i ; j ++ )

{

System. out. println ( a++ ) ;

}

System. out. print ( ) ;

}

break ;

default :

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

}

}

}

▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃

❃ Switch case is a type of program in java where the user is given obviously a choice as there exists more than one program

❃ Follow the semicolon ; each and every where minutely

Similar questions