Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package edu.oakland.production.homework;
- import java.util.*;
- public class TemperatureByCricket{
- public static float getTemp(float chirps){
- float temp;
- temp = chirps/4;
- temp += 40;
- return temp;
- }
- public static void main(String[] args){
- Scanner s = new Scanner(System.in);
- float chirps;
- while(true){
- System.out.print("Please enter the number of chirps per minute, or -1 to quit. ");
- chirps = s.nextFloat();
- if(chirps == -1)
- break;
- else if(chirps < 0)
- System.out.println("Error: negative chirps");
- else
- System.out.println("The temperature is " + getTemp(chirps) + "F.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement