Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribedThe 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

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

Recommended Textbook for

PostgreSQL 10 High Performance Expert Techniques For Query Optimization High Availability And Efficient Database Maintenance

Authors: Ibrar Ahmed ,Gregory Smith ,Enrico Pirozzi

3rd Edition

1788474481, 978-1788474481

More Books

Students also viewed these Databases questions

Question

Q: Answer the following: ceil ( - 8 . 8 ) floor ( - 9 . 3

Answered: 1 week ago