Question: The picture is the prompt, and the code is attached below. We are expected to use this code as the basis to complete the prompt.

The picture is the prompt, and the code is attached below. WeThe picture is the prompt, and the code is attached below. We are expected to use this code as the basis to complete the prompt.

import java.util.Scanner;

public class SevenAndNotLeft { public static void main(String[] args) { // Do not edit this method Scanner keyboard = new Scanner(System.in); int first = keyboard.nextInt(); int second = keyboard.nextInt(); int third = keyboard.nextInt(); System.out.println(sevenAndNotLeft(first, second, third)); keyboard.close(); }

public static int sevenAndNotLeft(int first, int second, int third) { // Put your code here } }

22.4 Seven And Not Left Given 3 int values, a b c, return their sum. However, if any of the values is 7 then it does not count towards the sum and all values to the left of any 7 do not count. So for example, if b is 7, then both a and b do not count. If b and c are 7, then none of the values count. sevenAndNotLeft(1, 2, 3) 6 sevenAndNotLeft(1, 2, 7) + 0 sevenAndNotLeft(1, 7,3) + 3 Hint: Carefully consider the ordering of the cases

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!