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. 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 casesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started