// Example Test (S1234567): Program output is 4.714285...
// Test (Enter your student number here): Program output is ...
import java.util.Scanner; // Needed for the scanner class
// You can add import statements here if you wish
public class Assignment2
{
// Do not make any modifications above this line
public static int mystery(String i)
{
;
double a = new Integer(i);
double c = 0;
double b = 0;
System.out.println("Testing i" + " " + i);
b = (a + a);
c = new Integer(i);
System.out.println("Testing a" + " " + a);
System.out.println ("ading numbers" + " " +b);
// System.out.println ("avg" + " " + (b / index));
return (int) b; // You will need to modify this line
}
public static void runProgram()
{
String i; // to get the keyboard input
double index = 0; //This will hold the count
do {
Scanner keyboard = new Scanner(System.in); //Create a Scabber object to read input
System.out.print("\nPlease enter a Number! "); //get the input from the user from the keyboard
i = keyboard.nextLine();
mystery(i);
index ++;
// System.out.println ("counting the number" + " " + (index ));
// System.out.println ("avg" + " " + (mystery(i) / index));
}while (new Integer(i) > 0);
}
// Do not make any modifications below this line
public static void main(String args[])
{
runProgram();
}
}
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.