Phone call cost 10 cents per minute. Write a program that generate two random numbers and calculate the cost of the call.
When a button is clicked ,two random numbers are generated,.A call cannot be more than 5 hours long.The generated hours and minutes are displayed on labels.
When a button is clicked ,two random numbers are generated,.A call cannot be more than 5 hours long.The generated hours and minutes are displayed on labels. How to Calculate the cost of the call in minutes and display it on a label?
1
Expert's answer
2012-08-23T08:48:18-0400
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace WindowsFormsApplication1 { public partial class Form1 : Form { & public Form1() & { InitializeComponent(); label1.Text = ""; label2.Text = ""; label3.Text = ""; & }
& private void button1_Click(object sender, EventArgs e) & { int hour, minutes; Random random = new Random(); hour = random.Next(0,4); minutes = random.Next(0,59); label1.Text = Convert.ToString(hour); label2.Text = ": quot; + Convert.ToString(minutes); int cost = (minutes + (60 * hour)) * 10; label3.Text = Convert.ToString(cost); & } } }
Comments
Leave a comment