Question: I keep getting the wrong out put for when I enter 0 1 or 2 as if it thinks a[0] could equal 0 and the
I keep getting the wrong out put for when I enter 0 1 or 2 as if it thinks a[0] could equal 0 and the element value in the area given by the user. What Am I doing wrong? For case 4 we are supposed to find the min number from the user giving us 3 numbers and tell them if there are more than one minimum( If they put the same interger twice ex: 5 5 9)
package menu;
import java.util.Arrays; import java.util.IntSummaryStatistics; import java.util.Scanner;
public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println(" 1)First Name 2)Last Name 3)Date 4)Find min 0)Exit"); int choice = input.nextInt(); switch(choice){ case 1 -> System.out.println("First Name"); case 2 -> System.out.println("Last Name"); case 3 -> System.out.println("Feburary 6th, 2021"); case 4 -> { System.out.println("Give three numbers to find a minimum of the three, enter one at a time"); int a[] = new int[3]; for (int i = 0; i < 3; i++){ a[i] = input.nextInt();} IntSummaryStatistics iss = Arrays.stream(a).summaryStatistics(); System.out.println("The minimum value is:" + iss.getMin());
if (iss.getMin() == (a[0] & a[1]) | iss.getMin() == (a[1] & a[2]) | iss.getMin() == (a[0] & a[2])){ System.out.println("There are two minimums"); break;} default:} } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
