Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Based on the coding below, create the flow chart and UML diagram import java.util.*; import java.math.*; public class Main { public static void main(String[] args)

Based on the coding below, create the flow chart and UML diagram

import java.util.*; import java.math.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // Create a Scanner object System.out.println("Enter 1 for water bill, 2 for electriccity bill, 3 for telephone bill"); int a = sc.nextInt(); Scanner avg = new Scanner(System.in); System.out.println("Enter number of months you want to get average bill of(from 1 to 12): "); int n = avg.nextInt(); Scanner unit = new Scanner(System.in); System.out.println("Enter units consumed in " +n+ " months"); int x = unit.nextInt(); if(a == 1 && n<13) { Scanner wb= new Scanner(System.in); System.out.println("Enter water bill units consumed this month"); int waterbill = wb.nextInt(); double waterbillamt = waterbill * 4.40; System.out.println("Your water bill for this month is: " +waterbillamt+" MYR"); double avgbill = (x * 4.40)/n; System.out.println("Your average water bill for "+n+" months is: " +avgbill+" MYR"); } else if(a == 2 && n<13) { Scanner eb= new Scanner(System.in); System.out.println("Enter electric city bill units consumed this month"); int electriccitybill = eb.nextInt(); double electriccitybillamt = electriccitybill * 0.516; System.out.println("Your electric city bill for this month is: " +electriccitybillamt+" MYR"); double avgbill = (x * 0.516)/n; System.out.println("Your average electric city bill for "+n+" months is: " +avgbill+" MYR"); } else if(a == 3 && n<13) { Scanner tb= new Scanner(System.in); System.out.println("Enter telephone bill units consumed this month"); int telephonebill = tb.nextInt(); double telephonebillbillamt = telephonebill * 2.5; System.out.println("Your telephone bill for this month is: " +telephonebillbillamt+" MYR"); double avgbill = (x * 2.5)/n; System.out.println("Your average telephone bill for "+n+" months is: " +avgbill+" MYR"); } else { if(n>12 && a<=3) { System.out.println("Enter average number of months only between 1 to 12"); } else if(n<13 && a>3) { System.out.println("Please insert a correct a value 1,2 or 3 for water,electriccity and telephone respectively"); } } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago