Trying to write a C# program, everytime l try and run it it fails and says they are errors.Below screenshot is for the problem Write a program to calculate electricity charges for a customer. The program requests a name, previous meter reading and current meter reading. The difference in the two readings gives the number of units of electricity used. The customer pays a fixed charge of $25. In addition to the fixed charge, 20 cents is charged for each unit used. Print all the data, the number of units used and the amount the customer must pay, appropriately labelled.   Additional information: You may assume that the current meter reading is larger than or equat to the previous meter reading. You may assume all data entered into your program is correct

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter3: Data Representation
Section: Chapter Questions
Problem 3RP
icon
Related questions
Question

Trying to write a C# program, everytime l try and run it it fails and says they are errors.Below screenshot is for the problem

Write a program to calculate electricity charges for a customer. The program requests a name, previous meter reading and current meter reading. The difference in the two readings gives the number of units of electricity used. The customer pays a fixed charge of $25. In addition to the fixed charge, 20 cents is charged for each unit used.

Print all the data, the number of units used and the amount the customer must pay, appropriately labelled.

 

Additional information:

  1. You may assume that the current meter reading is larger than or equat to the previous meter reading.
  2. You may assume all data entered into your program is correct
File
Edit
View
Git
Project
Build
Debug
Test
Analyze
Tools
Extensions
Window
Help
Search (Ctrl+Q)
ConsoleApp1
TM
Debug
Any CPU
• ConsoleApp1 -
三
A Live Share
Program.cs* + x
Solution Explorer
CH ConsoleApp1
, ConsoleApp1.Program
Main(string[] args)
1
using System;
Search Solution Explorer (Ctrl+;)
A Solution 'ConsoleApp1' (1 of 1 project)
= ConsoleApp1
* Dependencies
Onamespace ConsoleApp1
4
O references
class Program
C# Program.cs
{
O references
static void Main(string[] args)
7
8
// taking input from user
Console.WriteLine("Enter username:");
string userName = Console.ReadLine();
Console.WriteLine("Username is: " + userName);
10
11
12
13
//taking readings from user(current and previous reading)
Console.Writeline("Please enter current reading: ");
current = Convert.ToInt32(Console.ReadLine());
Console.Writeline("Please enter previous reading: ");
previous = Convert.ToInt32(Console.ReadLine());
total = current - previous
14
15
16
17
18
Solution Explorer Git Changes
19
Properties
20
console.writeline(“Difference is;" +total;
21
22
int fixedprice = 25;
事
int units = 250;// unit consumed
int bill = (units * 20) + 25; //to clalculate bill
Console.Writeline("Amount to pay:" + bill);
23
24
25
26
27
28
29
30
100 %
X 17
A 1
+ →| V
Ln: 16
Ch: 13
SPC
CRLF
O Ready
Toolbox
Transcribed Image Text:File Edit View Git Project Build Debug Test Analyze Tools Extensions Window Help Search (Ctrl+Q) ConsoleApp1 TM Debug Any CPU • ConsoleApp1 - 三 A Live Share Program.cs* + x Solution Explorer CH ConsoleApp1 , ConsoleApp1.Program Main(string[] args) 1 using System; Search Solution Explorer (Ctrl+;) A Solution 'ConsoleApp1' (1 of 1 project) = ConsoleApp1 * Dependencies Onamespace ConsoleApp1 4 O references class Program C# Program.cs { O references static void Main(string[] args) 7 8 // taking input from user Console.WriteLine("Enter username:"); string userName = Console.ReadLine(); Console.WriteLine("Username is: " + userName); 10 11 12 13 //taking readings from user(current and previous reading) Console.Writeline("Please enter current reading: "); current = Convert.ToInt32(Console.ReadLine()); Console.Writeline("Please enter previous reading: "); previous = Convert.ToInt32(Console.ReadLine()); total = current - previous 14 15 16 17 18 Solution Explorer Git Changes 19 Properties 20 console.writeline(“Difference is;" +total; 21 22 int fixedprice = 25; 事 int units = 250;// unit consumed int bill = (units * 20) + 25; //to clalculate bill Console.Writeline("Amount to pay:" + bill); 23 24 25 26 27 28 29 30 100 % X 17 A 1 + →| V Ln: 16 Ch: 13 SPC CRLF O Ready Toolbox
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning