Skip to content

Instantly share code, notes, and snippets.

@andreinechaev
Created April 19, 2014 15:27
Show Gist options
  • Save andreinechaev/11087621 to your computer and use it in GitHub Desktop.
Save andreinechaev/11087621 to your computer and use it in GitHub Desktop.
for Ivan
package com.javarush.test.level03.lesson06.task03;
/* Семь цветов радуги
Выведи на экран текст: семь цветов радуги.
В каждой строке должно быть по три цвета, в последней - один.
Цвета разделяй пробелом.
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Solution
{
public static void main(String[] args) throws Exception
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int sum = 0;
int add;
String text = "сумма";
while (true){
String s = reader.readLine();
if (s.equals(text)) {
break;
}
add = Integer.parseInt(s.trim());
sum += add;
}
System.out.println(sum);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment