Chat AWhile CS: C# HW PDF

Title Chat AWhile CS: C# HW
Course Advanced Programming
Institution University of Arkansas at Little Rock
Pages 2
File Size 35.6 KB
File Type PDF
Total Downloads 81
Total Views 140

Summary

Chat AWhile CS: C# HW...


Description

//Author: //Date: 03/07/2019 //BINS 4314, HW5-P2 using System; using static System.Console; class ChatAWhile { static void Main() { //initializer lists for array variables double[] areaCodes = {262, 414, 608, 715, 815, 920}; double[] rates=

{.07, .10, .05, .16, .24, .14};

bool isValidItem = false;//boolean value to be used for determining if user input matches areaCodes array. //double variables for call length assignment, user input area code assignment, and double variables used to determine price per minute. double callLength; double callPrice; double code; double cost = 0;

int x; //displays output that request user input WriteLine("Enter the area code that you are calling: "); code = Convert.ToDouble(ReadLine());//converts to double and assigns to variable WriteLine("Enter the length of time for the call in minutes: "); callLength = Convert.ToDouble(ReadLine()); //for loop that will search areaCodes array to determine if user input for area code matches value in areaCodes array for(x = 0; x < areaCodes.Length; ++x)

{ //if user input matches array element, boolean is true, rates array element in same position as matched areaCodes element is assigned to cost. if(code == areaCodes[x]) { isValidItem = true; cost = rates[x];

} } callPrice = cost * callLength;//calculates cost per-minute

if(isValidItem)//if true, following output is displayed to console { WriteLine("Your phone call to area {0} costs ${1} per minute \nFor {2} minutes the total is ${3}", code, cost, callLength, callPrice); } else//if not true, following output is displayed { WriteLine("Sorry - no calls allowed to area {0}", code); } } }...


Similar Free PDFs