import java.util.Scanner;
public class AlqudA2Q2 {
**///created by computer_sorry///*
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("This calculates the amount of positive and negative values,\n"
+ "the total, and the average of the integers you enter.");
System.out.println("Enter an integer value, the program exits if it is 0.");
int data=input.nextInt();
int sum = 0;
int count =0;
int totpos = 0;
int totneg = 0;
double average = 0;
*////computer_sorry 2012////*
while (data!=0){
sum += data;
average = sum/data;
System.out.println("Enter an integer value, the program exits if it is 0.");
data=input.nextInt();
count++;
*////computer_sorry 2012////*
if (data>0)
totpos++;
if (data<0)
totneg++;
}
System.out.println("The amount of positive integers is" +totpos);
System.out.println("The amount of negative integers is" +totneg);
System.out.println("The total of the integers is" +sum);
System.out.println("The average of the integers is" +average);
}
}
This post has been edited by smohd: 10 February 2012 - 12:52 PM
Reason for edit:: Code tags added. Please use [code] tags when posting codes

New Topic/Question
Reply




MultiQuote




|