Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Collections;
- namespace TempList
- {
- class Program
- {
- static void Main(string[] args)
- {
- /* Write a program that accepts seven int values represnting the high temps for seven consecutive days (done)
- * Display each of the values along with a message that indicates how far it is from the average (WIP)
- *
- *
- * */
- int temp0, temp1, temp2, temp3, temp4, temp5, temp6;
- int[] temps = new int[7];
- int total = 0;
- int avg = 0;
- int off = 0; //Stores how far off from the average each temperature is.
- temp0 = temps[0];
- temp1 = temps[1];
- temp2 = temps[2];
- temp3 = temps[3];
- temp4 = temps[4];
- temp5 = temps[5];
- temp6 = temps[6];
- Console.WriteLine("Enter temp 1: ");
- temp0 = Int32.Parse(Console.ReadLine());
- total += temp0;
- Console.WriteLine("Enter temp 2: ");
- temp1 = Int32.Parse(Console.ReadLine());
- total += temp1;
- Console.WriteLine("Enter temp 3: ");
- temp2 = Int32.Parse(Console.ReadLine());
- total += temp2;
- Console.WriteLine("Enter temp 4: ");
- temp3 = Int32.Parse(Console.ReadLine());
- total += temp3;
- Console.WriteLine("Enter temp 5: ");
- temp4 = Int32.Parse(Console.ReadLine());
- total += temp4;
- Console.WriteLine("Enter temp 6: ");
- temp5 = Int32.Parse(Console.ReadLine());
- total += temp5;
- Console.WriteLine("Enter temp 7: ");
- temp6 = Int32.Parse(Console.ReadLine());
- total += temp6;
- avg = total / 7;
- Console.WriteLine("The average of all 7 temps is: {0}.", avg);
- foreach (int i in temps)
- {
- Console.WriteLine(i);//This prints "0" every time.
- //Console.WriteLine("{0} is {1} away from the average of {3}", i, off, avg); <- target output
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement