0

Code Coach Problem(Fruit Bowl)

I can’t seem to work out how to integrate my code with the code that’s already there, can anyone help me with this please?

4th Feb 2020, 8:53 AM
Shania
Shania - avatar
10 ответов
+ 7
Java's output statement is System.out.println(fruit) ; System.out.print(fruit) ; //this don't put newline after, but above does... Not document.write(); //this is in JavaScript.. Read before attempting for a good practice: See this in System.out.println topic(3rd) https://www.sololearn.com/learn/Java/2137/?ref=app
4th Feb 2020, 9:15 AM
Jayakrishna 🇮🇳
+ 2
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); int fruit = input.nextInt(); int apple,banana,pie; //your code goes here if(fruit>6){ apple=fruit/2; pie=apple/3; System.out.println(pie); } else System.out.println("0"); } }
11th Feb 2022, 8:41 AM
Rashmi Jayasekara
Rashmi Jayasekara - avatar
+ 1
Write Program and hit run. You will see in output part.. It will show 2 examples with expected output. With the output you are getting.. Remaing are hidden..
4th Feb 2020, 9:07 AM
Jayakrishna 🇮🇳
+ 1
Thank you so much 😊👍🏻
4th Feb 2020, 9:30 AM
Shania
Shania - avatar
0
It had built the read input line. You focus on the calculations. At last, print the result to console.
4th Feb 2020, 8:57 AM
Gordon
Gordon - avatar
0
You just need to continue... After // your code goes here... Write logic here... Complete program.
4th Feb 2020, 8:58 AM
Jayakrishna 🇮🇳
0
Thank you, how can i output my calculations?
4th Feb 2020, 9:05 AM
Shania
Shania - avatar
0
It doesnt allow me to use document.write() or return, is there another thing i can try?
4th Feb 2020, 9:09 AM
Shania
Shania - avatar
0
This is my code import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); int fruit = input.nextInt(); fruit /= 2; fruit /= 3; } } Is fruit the right varible to use?
4th Feb 2020, 9:13 AM
Shania
Shania - avatar
0
Wel come... Shania
4th Feb 2020, 11:24 AM
Jayakrishna 🇮🇳