Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Control flow testing Activity Question 1: Consider the code shown below : package activity9; import java.util.Scanner; public class Activity9 { public static void main(String[] args)

Control flow testing Activity

Question 1: Consider the code shown below :

package activity9;

import java.util.Scanner;

public class Activity9 {

public static void main(String[] args) {

// TODO code application logic hereScanner input = new Scanner(System.in);

int choice = 0;

double celsius, fahrenheit, inches, centimeters;

char doAgain = 'y';

while (doAgain == 'y' || doAgain == 'Y')

{

System.out.print(" Main Menu 1. Celsius to Fahrenheit 2. Inches to Centimeters "

+ "Please select either 1 or 2 Then press enter to continue");

choice = input.nextInt();

if (choice == 1)

{

System.out.println("This program will convert a celsius value into a fahrenheit one. ");

System.out.println("Please enter the tempature for conversion: ");

celsius = input.nextInt();

fahrenheit = 1.8 * celsius + 32.0;

System.out.println(celsius + " degree(s) in celcius" + " is " + fahrenheit +

" in fahrenheit. ");

System.out.println("Do you want to continue? : " +

"enter a \'y \' for another round " +

" enter a\'n\' to end the program ");

doAgain = input.next().charAt(0);

}

else if (choice == 2)

{

System.out.println("This program will convert inches to centimeters. ");

System.out.println("Please enter the length for conversion: ");

inches = input.nextInt();

centimeters = 2.54 * inches;

System.out.println(inches + " inches is " + centimeters + " centimeters. ");

System.out.println("Do you want to continue? : " +

"enter a \'y \' for another round " +

" enter a\'n\' to end the program ");

doAgain = input.next().charAt(0);

}

else

{

System.out.println("That is not a valid option. Please restart and try again");

}

}

}

}

1Draw control flow graph (CFG) for the above code

2Compute the McCabe cyclomatic complexity number

3List the logical paths

4Give an example of the initial values of variables ( doAgain and choice ) to execute each path.

5List the paths that are required to cover all the statements.

6List the paths that are required to cover all the branches.

7List the paths that are required to cover all the paths

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Discuss five types of employee training.

Answered: 1 week ago

Question

Identify the four federally mandated employee benefits.

Answered: 1 week ago