Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.29 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Collections;
  7.  
  8.  
  9. namespace TempList
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             /* Write a program that accepts seven int values represnting the high temps for seven consecutive days (done)
  16.              * Display each of the values along with a message that indicates how far it is from the average (WIP)
  17.              *
  18.              *
  19.              * */
  20.             int temp0, temp1, temp2, temp3, temp4, temp5, temp6;
  21.             int[] temps = new int[7];
  22.             int total = 0;
  23.             int avg = 0;
  24.             int off = 0; //Stores how far off from the average each temperature is.
  25.             temp0 = temps[0];
  26.             temp1 = temps[1];
  27.             temp2 = temps[2];
  28.             temp3 = temps[3];
  29.             temp4 = temps[4];
  30.             temp5 = temps[5];
  31.             temp6 = temps[6];
  32.             Console.WriteLine("Enter temp 1: ");
  33.             temp0 = Int32.Parse(Console.ReadLine());
  34.             total += temp0;
  35.             Console.WriteLine("Enter temp 2: ");
  36.             temp1 = Int32.Parse(Console.ReadLine());
  37.             total += temp1;
  38.             Console.WriteLine("Enter temp 3: ");
  39.             temp2 = Int32.Parse(Console.ReadLine());
  40.             total += temp2;
  41.             Console.WriteLine("Enter temp 4: ");
  42.             temp3 = Int32.Parse(Console.ReadLine());
  43.             total += temp3;
  44.             Console.WriteLine("Enter temp 5: ");
  45.             temp4 = Int32.Parse(Console.ReadLine());
  46.             total += temp4;
  47.             Console.WriteLine("Enter temp 6: ");
  48.             temp5 = Int32.Parse(Console.ReadLine());
  49.             total += temp5;
  50.             Console.WriteLine("Enter temp 7: ");
  51.             temp6 = Int32.Parse(Console.ReadLine());
  52.             total += temp6;
  53.             avg = total / 7;
  54.             Console.WriteLine("The average of all 7 temps is: {0}.", avg);
  55.             foreach (int i in temps)
  56.             {
  57.                 Console.WriteLine(i);//This prints "0" every time.
  58.                 //Console.WriteLine("{0} is {1} away from the average of {3}", i, off, avg); <- target output
  59.             }
  60.             Console.ReadKey();
  61.         }        
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement