WeixiangYan/CodeTransOcean huggingface dataset:
Task: Soloway's recurring rainfall



C#: namespace RosettaCode
{
	class CSharpRecurringRainfall
    {		
		static int ReadNextInput()
		{
			System.Console.Write("Enter rainfall int, 99999 to quit: ");
			string input = System.Console.ReadLine();
			
			if (System.Int32.TryParse(input, out int num))
			{
				return num;
			}
			else
			{
				System.Console.WriteLine("Invalid input");
				return ReadNextInput();
			}
		}
		
        static void Main()
        {
			double currentAverage = 0;
			int currentEntryNumber = 0;
			
            for (int lastInput = ReadNextInput(); lastInput != 99999; lastInput = ReadNextInput())
            {
				currentEntryNumber++;
				currentAverage = currentAverage + (1.0/(float)currentEntryNumber)*lastInput - (1.0/(float)currentEntryNumber)*currentAverage;
				System.Console.WriteLine("New Average: " + currentAverage);
			}
        }
    }
}









Ada: with Ada.Text_IO; 
with Ada.Text_IO.Unbounded_IO;
with Ada.Strings.Unbounded;
with Ada.Integer_Text_IO;
with Ada.IO_Exceptions;

procedure RecurringRainfall is
   Current_Average : Float := 0.0;
   Current_Count : Integer := 0;
   Input_Integer : Integer;
   
   
   function Get_Next_Input return Integer is
      Input_Integer : Integer;
      Clear_String : Ada.Strings.Unbounded.Unbounded_String;
   begin
      Ada.Text_IO.Put("Enter rainfall int, 99999 to quit: ");
      Ada.Integer_Text_IO.Get(Input_Integer);
      return Input_Integer;
   exception
      when Ada.IO_Exceptions.Data_Error => 
         Ada.Text_IO.Put_Line("Invalid input");
         
         
         pragma Warnings (Off, Clear_String);
         Clear_String := Ada.Text_IO.Unbounded_IO.Get_Line;
         
         
         
         
         pragma Warnings (Off, "infinite recursion");
         return Get_Next_Input;
         pragma Warnings (On, "infinite recursion");
   end Get_Next_Input;

begin
   loop
      Input_Integer := Get_Next_Input;
      exit when Input_Integer = 99999;
      
	  Current_Count := Current_Count + 1;
      Current_Average := Current_Average + (Float(1) / Float(Current_Count))*Float(Input_Integer) - (Float(1) / Float(Current_Count))*Current_Average;
      
      Ada.Text_IO.Put("New Average: ");
      Ada.Text_IO.Put_Line(Float'image(Current_Average));
      
   end loop;
end RecurringRainfall;
Task: Soloway's recurring rainfall

C: #include <stdio.h>

int main(int argc, char **argv)
{
	
	(void)argc;
	(void)argv;
	
	float currentAverage = 0;
	unsigned int currentEntryNumber = 0;
	
	for (;;)
	{
		int ret, entry;
		
		printf("Enter rainfall int, 99999 to quit: ");
		ret = scanf("%d", &entry);
		
		if (ret)
		{
			if (entry == 99999)
			{
				printf("User requested quit.\n");
				break;
			}
			else
			{
				currentEntryNumber++;
				currentAverage = currentAverage + (1.0f/currentEntryNumber)*entry - (1.0f/currentEntryNumber)*currentAverage;
				
				printf("New Average: %f\n", currentAverage);
			}
		}
		else
		{
			printf("Invalid input\n");
			while (getchar() != '\n');	
		}
	}
	
	return 0;
}











Ada: with Ada.Text_IO; 
with Ada.Text_IO.Unbounded_IO;
with Ada.Strings.Unbounded;
with Ada.Integer_Text_IO;
with Ada.IO_Exceptions;

procedure RecurringRainfall is
   Current_Average : Float := 0.0;
   Current_Count : Integer := 0;
   Input_Integer : Integer;
   
   
   function Get_Next_Input return Integer is
      Input_Integer : Integer;
      Clear_String : Ada.Strings.Unbounded.Unbounded_String;
   begin
      Ada.Text_IO.Put("Enter rainfall int, 99999 to quit: ");
      Ada.Integer_Text_IO.Get(Input_Integer);
      return Input_Integer;
   exception
      when Ada.IO_Exceptions.Data_Error => 
         Ada.Text_IO.Put_Line("Invalid input");
         
         
         pragma Warnings (Off, Clear_String);
         Clear_String := Ada.Text_IO.Unbounded_IO.Get_Line;
         
         
         
         
         pragma Warnings (Off, "infinite recursion");
         return Get_Next_Input;
         pragma Warnings (On, "infinite recursion");
   end Get_Next_Input;

begin
   loop
      Input_Integer := Get_Next_Input;
      exit when Input_Integer = 99999;
      
	  Current_Count := Current_Count + 1;
      Current_Average := Current_Average + (Float(1) / Float(Current_Count))*Float(Input_Integer) - (Float(1) / Float(Current_Count))*Current_Average;
      
      Ada.Text_IO.Put("New Average: ");
      Ada.Text_IO.Put_Line(Float'image(Current_Average));
      
   end loop;
end RecurringRainfall;
Task: Soloway's recurring rainfall


C++: #include <iostream>
#include <limits>

int main()
{
	float currentAverage = 0;
	unsigned int currentEntryNumber = 0;
	
	for (;;)
	{
		int entry;
		
		std::cout << "Enter rainfall int, 99999 to quit: ";
		std::cin >> entry;
		
		if (!std::cin.fail())
		{
			if (entry == 99999)
			{
				std::cout << "User requested quit." << std::endl;
				break;
			}
			else
			{
				currentEntryNumber++;
				currentAverage = currentAverage + (1.0f/currentEntryNumber)*entry - (1.0f/currentEntryNumber)*currentAverage;
				
				std::cout << "New Average: " << currentAverage << std::endl;
			}
		}
		else
		{
			std::cout << "Invalid input" << std::endl;
			std::cin.clear();
			std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
		}
	}
	
	return 0;
}










Ada: with Ada.Text_IO; 
with Ada.Text_IO.Unbounded_IO;
with Ada.Strings.Unbounded;
with Ada.Integer_Text_IO;
with Ada.IO_Exceptions;

procedure RecurringRainfall is
   Current_Average : Float := 0.0;
   Current_Count : Integer := 0;
   Input_Integer : Integer;
   
   
   function Get_Next_Input return Integer is
      Input_Integer : Integer;
      Clear_String : Ada.Strings.Unbounded.Unbounded_String;
   begin
      Ada.Text_IO.Put("Enter rainfall int, 99999 to quit: ");
      Ada.Integer_Text_IO.Get(Input_Integer);
      return Input_Integer;
   exception
      when Ada.IO_Exceptions.Data_Error => 
         Ada.Text_IO.Put_Line("Invalid input");
         
         
         pragma Warnings (Off, Clear_String);
         Clear_String := Ada.Text_IO.Unbounded_IO.Get_Line;
         
         
         
         
         pragma Warnings (Off, "infinite recursion");
         return Get_Next_Input;
         pragma Warnings (On, "infinite recursion");
   end Get_Next_Input;

begin
   loop
      Input_Integer := Get_Next_Input;
      exit when Input_Integer = 99999;
      
	  Current_Count := Current_Count + 1;
      Current_Average := Current_Average + (Float(1) / Float(Current_Count))*Float(Input_Integer) - (Float(1) / Float(Current_Count))*Current_Average;
      
      Ada.Text_IO.Put("New Average: ");
      Ada.Text_IO.Put_Line(Float'image(Current_Average));
      
   end loop;
end RecurringRainfall;
Task: Soloway's recurring rainfall





Java: class recurringrainfall
{ 
	private static int GetNextInt()
	{
		while (true)
		{
			System.out.print("Enter rainfall int, 99999 to quit: ");
			String input = System.console().readLine();
        
			try
			{
				int n = Integer.parseInt(input);
				return n;
			}
			catch (Exception e)
			{
				System.out.println("Invalid input");
			}
		}
	}
	
    private static void recurringRainfall() {
		float currentAverage = 0;
		int currentEntryNumber = 0;
		
		while (true) {
			int entry = GetNextInt();
			
			if (entry == 99999)
				return;
			
			currentEntryNumber++;
			currentAverage = currentAverage + ((float)1/currentEntryNumber)*entry - ((float)1/currentEntryNumber)*currentAverage;
			
			System.out.println("New Average: " + currentAverage);
		}
    }
    
    public static void main(String args[]) { 
        recurringRainfall();
    } 
}







Ada: with Ada.Text_IO; 
with Ada.Text_IO.Unbounded_IO;
with Ada.Strings.Unbounded;
with Ada.Integer_Text_IO;
with Ada.IO_Exceptions;

procedure RecurringRainfall is
   Current_Average : Float := 0.0;
   Current_Count : Integer := 0;
   Input_Integer : Integer;
   
   
   function Get_Next_Input return Integer is
      Input_Integer : Integer;
      Clear_String : Ada.Strings.Unbounded.Unbounded_String;
   begin
      Ada.Text_IO.Put("Enter rainfall int, 99999 to quit: ");
      Ada.Integer_Text_IO.Get(Input_Integer);
      return Input_Integer;
   exception
      when Ada.IO_Exceptions.Data_Error => 
         Ada.Text_IO.Put_Line("Invalid input");
         
         
         pragma Warnings (Off, Clear_String);
         Clear_String := Ada.Text_IO.Unbounded_IO.Get_Line;
         
         
         
         
         pragma Warnings (Off, "infinite recursion");
         return Get_Next_Input;
         pragma Warnings (On, "infinite recursion");
   end Get_Next_Input;

begin
   loop
      Input_Integer := Get_Next_Input;
      exit when Input_Integer = 99999;
      
	  Current_Count := Current_Count + 1;
      Current_Average := Current_Average + (Float(1) / Float(Current_Count))*Float(Input_Integer) - (Float(1) / Float(Current_Count))*Current_Average;
      
      Ada.Text_IO.Put("New Average: ");
      Ada.Text_IO.Put_Line(Float'image(Current_Average));
      
   end loop;
end RecurringRainfall;
Task: Soloway's recurring rainfall







Python: import sys

def get_next_input():
    try:
        num = int(input("Enter rainfall int, 99999 to quit: "))
    except:
        print("Invalid input")
        return get_next_input()
    return num

current_average = 0.0
current_count = 0

while True:
    next = get_next_input()

    if next == 99999:
        sys.exit()
    else:
        current_count += 1
        current_average = current_average + (1.0/current_count)*next - (1.0/current_count)*current_average
        
        print("New average: ", current_average)





Ada: with Ada.Text_IO; 
with Ada.Text_IO.Unbounded_IO;
with Ada.Strings.Unbounded;
with Ada.Integer_Text_IO;
with Ada.IO_Exceptions;

procedure RecurringRainfall is
   Current_Average : Float := 0.0;
   Current_Count : Integer := 0;
   Input_Integer : Integer;
   
   
   function Get_Next_Input return Integer is
      Input_Integer : Integer;
      Clear_String : Ada.Strings.Unbounded.Unbounded_String;
   begin
      Ada.Text_IO.Put("Enter rainfall int, 99999 to quit: ");
      Ada.Integer_Text_IO.Get(Input_Integer);
      return Input_Integer;
   exception
      when Ada.IO_Exceptions.Data_Error => 
         Ada.Text_IO.Put_Line("Invalid input");
         
         
         pragma Warnings (Off, Clear_String);
         Clear_String := Ada.Text_IO.Unbounded_IO.Get_Line;
         
         
         
         
         pragma Warnings (Off, "infinite recursion");
         return Get_Next_Input;
         pragma Warnings (On, "infinite recursion");
   end Get_Next_Input;

begin
   loop
      Input_Integer := Get_Next_Input;
      exit when Input_Integer = 99999;
      
	  Current_Count := Current_Count + 1;
      Current_Average := Current_Average + (Float(1) / Float(Current_Count))*Float(Input_Integer) - (Float(1) / Float(Current_Count))*Current_Average;
      
      Ada.Text_IO.Put("New Average: ");
      Ada.Text_IO.Put_Line(Float'image(Current_Average));
      
   end loop;
end RecurringRainfall;
Task: Soloway's recurring rainfall

C: #include <stdio.h>

int main(int argc, char **argv)
{
	
	(void)argc;
	(void)argv;
	
	float currentAverage = 0;
	unsigned int currentEntryNumber = 0;
	
	for (;;)
	{
		int ret, entry;
		
		printf("Enter rainfall int, 99999 to quit: ");
		ret = scanf("%d", &entry);
		
		if (ret)
		{
			if (entry == 99999)
			{
				printf("User requested quit.\n");
				break;
			}
			else
			{
				currentEntryNumber++;
				currentAverage = currentAverage + (1.0f/currentEntryNumber)*entry - (1.0f/currentEntryNumber)*currentAverage;
				
				printf("New Average: %f\n", currentAverage);
			}
		}
		else
		{
			printf("Invalid input\n");
			while (getchar() != '\n');	
		}
	}
	
	return 0;
}
Task: Soloway's recurring rainfall



C#: namespace RosettaCode
{
	class CSharpRecurringRainfall
    {		
		static int ReadNextInput()
		{
			System.Console.Write("Enter rainfall int, 99999 to quit: ");
			string input = System.Console.ReadLine();
			
			if (System.Int32.TryParse(input, out int num))
			{
				return num;
			}
			else
			{
				System.Console.WriteLine("Invalid input");
				return ReadNextInput();
			}
		}
		
        static void Main()
        {
			double currentAverage = 0;
			int currentEntryNumber = 0;
			
            for (int lastInput = ReadNextInput(); lastInput != 99999; lastInput = ReadNextInput())
            {
				currentEntryNumber++;
				currentAverage = currentAverage + (1.0/(float)currentEntryNumber)*lastInput - (1.0/(float)currentEntryNumber)*currentAverage;
				System.Console.WriteLine("New Average: " + currentAverage);
			}
        }
    }
}
Task: Soloway's recurring rainfall


C++: #include <iostream>
#include <limits>

int main()
{
	float currentAverage = 0;
	unsigned int currentEntryNumber = 0;
	
	for (;;)
	{
		int entry;
		
		std::cout << "Enter rainfall int, 99999 to quit: ";
		std::cin >> entry;
		
		if (!std::cin.fail())
		{
			if (entry == 99999)
			{
				std::cout << "User requested quit." << std::endl;
				break;
			}
			else
			{
				currentEntryNumber++;
				currentAverage = currentAverage + (1.0f/currentEntryNumber)*entry - (1.0f/currentEntryNumber)*currentAverage;
				
				std::cout << "New Average: " << currentAverage << std::endl;
			}
		}
		else
		{
			std::cout << "Invalid input" << std::endl;
			std::cin.clear();
			std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
		}
	}
	
	return 0;
}
Task: Soloway's recurring rainfall





Java: class recurringrainfall
{ 
	private static int GetNextInt()
	{
		while (true)
		{
			System.out.print("Enter rainfall int, 99999 to quit: ");
			String input = System.console().readLine();
        
			try
			{
				int n = Integer.parseInt(input);
				return n;
			}
			catch (Exception e)
			{
				System.out.println("Invalid input");
			}
		}
	}
	
    private static void recurringRainfall() {
		float currentAverage = 0;
		int currentEntryNumber = 0;
		
		while (true) {
			int entry = GetNextInt();
			
			if (entry == 99999)
				return;
			
			currentEntryNumber++;
			currentAverage = currentAverage + ((float)1/currentEntryNumber)*entry - ((float)1/currentEntryNumber)*currentAverage;
			
			System.out.println("New Average: " + currentAverage);
		}
    }
    
    public static void main(String args[]) { 
        recurringRainfall();
    } 
}
Task: Soloway's recurring rainfall







Python: import sys

def get_next_input():
    try:
        num = int(input("Enter rainfall int, 99999 to quit: "))
    except:
        print("Invalid input")
        return get_next_input()
    return num

current_average = 0.0
current_count = 0

while True:
    next = get_next_input()

    if next == 99999:
        sys.exit()
    else:
        current_count += 1
        current_average = current_average + (1.0/current_count)*next - (1.0/current_count)*current_average
        
        print("New average: ", current_average)
Task: Soloway's recurring rainfall



C#: namespace RosettaCode
{
	class CSharpRecurringRainfall
    {		
		static int ReadNextInput()
		{
			System.Console.Write("Enter rainfall int, 99999 to quit: ");
			string input = System.Console.ReadLine();
			
			if (System.Int32.TryParse(input, out int num))
			{
				return num;
			}
			else
			{
				System.Console.WriteLine("Invalid input");
				return ReadNextInput();
			}
		}
		
        static void Main()
        {
			double currentAverage = 0;
			int currentEntryNumber = 0;
			
            for (int lastInput = ReadNextInput(); lastInput != 99999; lastInput = ReadNextInput())
            {
				currentEntryNumber++;
				currentAverage = currentAverage + (1.0/(float)currentEntryNumber)*lastInput - (1.0/(float)currentEntryNumber)*currentAverage;
				System.Console.WriteLine("New Average: " + currentAverage);
			}
        }
    }
}








Fortran: function getNextInput() result(Input)
    implicit none
    integer :: Input
    integer :: Reason
    Reason = 1
    
    do while (Reason > 0)
        print *, "Enter rainfall int, 99999 to quit: "
        read (*,*,IOSTAT=Reason) Input
        
        if (Reason > 0) then
            print *, "Invalid input"
        end if
    enddo
    
end function getNextInput

program recurringrainfall
    implicit none
    real        :: currentAverage
    integer     :: currentCount
    integer     :: lastInput
    integer     :: getNextInput
    
    currentAverage = 0
    currentCount = 0

    do
        lastInput = getNextInput()
        
        if (lastInput == 99999) exit
        
        currentCount = currentCount + 1
        currentAverage = currentAverage + (1/real(currentCount))*lastInput - (1/real(currentCount))*currentAverage
        
        print *, 'New Average: ', currentAverage
    enddo 

    
end program recurringrainfall
Task: Soloway's recurring rainfall


C++: #include <iostream>
#include <limits>

int main()
{
	float currentAverage = 0;
	unsigned int currentEntryNumber = 0;
	
	for (;;)
	{
		int entry;
		
		std::cout << "Enter rainfall int, 99999 to quit: ";
		std::cin >> entry;
		
		if (!std::cin.fail())
		{
			if (entry == 99999)
			{
				std::cout << "User requested quit." << std::endl;
				break;
			}
			else
			{
				currentEntryNumber++;
				currentAverage = currentAverage + (1.0f/currentEntryNumber)*entry - (1.0f/currentEntryNumber)*currentAverage;
				
				std::cout << "New Average: " << currentAverage << std::endl;
			}
		}
		else
		{
			std::cout << "Invalid input" << std::endl;
			std::cin.clear();
			std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
		}
	}
	
	return 0;
}









Fortran: function getNextInput() result(Input)
    implicit none
    integer :: Input
    integer :: Reason
    Reason = 1
    
    do while (Reason > 0)
        print *, "Enter rainfall int, 99999 to quit: "
        read (*,*,IOSTAT=Reason) Input
        
        if (Reason > 0) then
            print *, "Invalid input"
        end if
    enddo
    
end function getNextInput

program recurringrainfall
    implicit none
    real        :: currentAverage
    integer     :: currentCount
    integer     :: lastInput
    integer     :: getNextInput
    
    currentAverage = 0
    currentCount = 0

    do
        lastInput = getNextInput()
        
        if (lastInput == 99999) exit
        
        currentCount = currentCount + 1
        currentAverage = currentAverage + (1/real(currentCount))*lastInput - (1/real(currentCount))*currentAverage
        
        print *, 'New Average: ', currentAverage
    enddo 

    
end program recurringrainfall
Task: Soloway's recurring rainfall

C: #include <stdio.h>

int main(int argc, char **argv)
{
	
	(void)argc;
	(void)argv;
	
	float currentAverage = 0;
	unsigned int currentEntryNumber = 0;
	
	for (;;)
	{
		int ret, entry;
		
		printf("Enter rainfall int, 99999 to quit: ");
		ret = scanf("%d", &entry);
		
		if (ret)
		{
			if (entry == 99999)
			{
				printf("User requested quit.\n");
				break;
			}
			else
			{
				currentEntryNumber++;
				currentAverage = currentAverage + (1.0f/currentEntryNumber)*entry - (1.0f/currentEntryNumber)*currentAverage;
				
				printf("New Average: %f\n", currentAverage);
			}
		}
		else
		{
			printf("Invalid input\n");
			while (getchar() != '\n');	
		}
	}
	
	return 0;
}










Fortran: function getNextInput() result(Input)
    implicit none
    integer :: Input
    integer :: Reason
    Reason = 1
    
    do while (Reason > 0)
        print *, "Enter rainfall int, 99999 to quit: "
        read (*,*,IOSTAT=Reason) Input
        
        if (Reason > 0) then
            print *, "Invalid input"
        end if
    enddo
    
end function getNextInput

program recurringrainfall
    implicit none
    real        :: currentAverage
    integer     :: currentCount
    integer     :: lastInput
    integer     :: getNextInput
    
    currentAverage = 0
    currentCount = 0

    do
        lastInput = getNextInput()
        
        if (lastInput == 99999) exit
        
        currentCount = currentCount + 1
        currentAverage = currentAverage + (1/real(currentCount))*lastInput - (1/real(currentCount))*currentAverage
        
        print *, 'New Average: ', currentAverage
    enddo 

    
end program recurringrainfall
Task: Soloway's recurring rainfall





Java: class recurringrainfall
{ 
	private static int GetNextInt()
	{
		while (true)
		{
			System.out.print("Enter rainfall int, 99999 to quit: ");
			String input = System.console().readLine();
        
			try
			{
				int n = Integer.parseInt(input);
				return n;
			}
			catch (Exception e)
			{
				System.out.println("Invalid input");
			}
		}
	}
	
    private static void recurringRainfall() {
		float currentAverage = 0;
		int currentEntryNumber = 0;
		
		while (true) {
			int entry = GetNextInt();
			
			if (entry == 99999)
				return;
			
			currentEntryNumber++;
			currentAverage = currentAverage + ((float)1/currentEntryNumber)*entry - ((float)1/currentEntryNumber)*currentAverage;
			
			System.out.println("New Average: " + currentAverage);
		}
    }
    
    public static void main(String args[]) { 
        recurringRainfall();
    } 
}






Fortran: function getNextInput() result(Input)
    implicit none
    integer :: Input
    integer :: Reason
    Reason = 1
    
    do while (Reason > 0)
        print *, "Enter rainfall int, 99999 to quit: "
        read (*,*,IOSTAT=Reason) Input
        
        if (Reason > 0) then
            print *, "Invalid input"
        end if
    enddo
    
end function getNextInput

program recurringrainfall
    implicit none
    real        :: currentAverage
    integer     :: currentCount
    integer     :: lastInput
    integer     :: getNextInput
    
    currentAverage = 0
    currentCount = 0

    do
        lastInput = getNextInput()
        
        if (lastInput == 99999) exit
        
        currentCount = currentCount + 1
        currentAverage = currentAverage + (1/real(currentCount))*lastInput - (1/real(currentCount))*currentAverage
        
        print *, 'New Average: ', currentAverage
    enddo 

    
end program recurringrainfall
Task: Soloway's recurring rainfall







Python: import sys

def get_next_input():
    try:
        num = int(input("Enter rainfall int, 99999 to quit: "))
    except:
        print("Invalid input")
        return get_next_input()
    return num

current_average = 0.0
current_count = 0

while True:
    next = get_next_input()

    if next == 99999:
        sys.exit()
    else:
        current_count += 1
        current_average = current_average + (1.0/current_count)*next - (1.0/current_count)*current_average
        
        print("New average: ", current_average)




Fortran: function getNextInput() result(Input)
    implicit none
    integer :: Input
    integer :: Reason
    Reason = 1
    
    do while (Reason > 0)
        print *, "Enter rainfall int, 99999 to quit: "
        read (*,*,IOSTAT=Reason) Input
        
        if (Reason > 0) then
            print *, "Invalid input"
        end if
    enddo
    
end function getNextInput

program recurringrainfall
    implicit none
    real        :: currentAverage
    integer     :: currentCount
    integer     :: lastInput
    integer     :: getNextInput
    
    currentAverage = 0
    currentCount = 0

    do
        lastInput = getNextInput()
        
        if (lastInput == 99999) exit
        
        currentCount = currentCount + 1
        currentAverage = currentAverage + (1/real(currentCount))*lastInput - (1/real(currentCount))*currentAverage
        
        print *, 'New Average: ', currentAverage
    enddo 

    
end program recurringrainfall