473,382 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

check money at ATM program

Directions:
Using the flowchart below, write the code to represent checking your balance at the ATM. The yellow diamonds represent conditional statements and the blue rectangles with rounded corners represent what should be printed to the console.

Flowchart for checking your balance at the ATM (Click the image to enlarge the flowchart).
Use the following variables in your solution:
balance - the account balance
isActive - if account is active
checkBalance - if you want to check balance
Hint: The variable balance could be a value less than, greater than, or equal to 0. The variables isActive and checkBalance are booleans that can be set to true or false.
TIP: To print out the account balance with decimal points (i.e. 325.00), use the .toFixed() method and pass it the number of decimal points you want to use. For example, balance.toFixed(2) returns 325.00.

TIP: Make sure to test your code with different values. For example,

If checkBalance equals true and isActive equals false, then Your account is no longer active. should be printed to the console.

My ANSWER was :

Expand|Select|Wrap|Line Numbers
  1. var balance = 7869000.00;
  2. var checkBalance = true;
  3. var isActive = true;
  4. if ( checkBalance === true && isActive === true && balance > 0.00) {
  5.  
  6.     console.log("Your balance is $" +  balance +".");
  7.     }
  8.     else if (checkBalance === false){
  9.         console.log("Thank you.Have a nice day!");
  10.     }
  11.  
  12.   else; if (checkBalance === true && isActive === false) {
  13.  
  14.      console.log("Your account is no longer active.") ; }
  15.  
  16.   else if (checkBalance === true && isActive === true && balance === 0.00)
  17. {
  18.      console.log("Your account is empty.");
  19.      }
  20.  
  21.      else if ( checkBalance === true && isActive === true && balance < 0.00) {
  22.          console.log("Your account is negative.Please contact bank.")}
HOWEVER I AM TOLD THAT THE ANSWER IS INCORRECT> Please do help.
Regards
Jan 6 '19 #1

✓ answered by gits

well - in your line 12 is a useless semicolon - which basically only ends the first chain of if-else-if conditions. the next block still runs as the semicolon before just marks an empty instruction after the else there. So its not really 'incorrect' but its a thing that should be fixed for the sake of not looking pointless there. Another thing is that you didnt use the hint with the toFixed method - which could be seen as something missing. since there obviously is a chart that shows exactly how the conditions should work - and we dont see that chart here - its guesswork if something is not implemented as it should be - besides the 2 things i could see and mentioned so far.

2 2315
gits
5,390 Expert Mod 4TB
well - in your line 12 is a useless semicolon - which basically only ends the first chain of if-else-if conditions. the next block still runs as the semicolon before just marks an empty instruction after the else there. So its not really 'incorrect' but its a thing that should be fixed for the sake of not looking pointless there. Another thing is that you didnt use the hint with the toFixed method - which could be seen as something missing. since there obviously is a chart that shows exactly how the conditions should work - and we dont see that chart here - its guesswork if something is not implemented as it should be - besides the 2 things i could see and mentioned so far.
Jan 8 '19 #2
Thanks Gits! you were right. Regards
Jan 8 '19 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Stefan Richter | last post by:
Hi, I am looking for a good function to check if a entered value is a money value - meaning it's a decimal with no more then 2 digits after the point. Thanks, Stefan
4
by: TM | last post by:
Is there any way to check if another instance of my program is running if a user executes it ? I would like to warn the user if the program is already running to prevent multiple instances. ...
8
by: Nikolay Petrov | last post by:
How could I check if my app is running. I would like to check if my app is running for specified user, because it is used in Terminal Server. I want the program to somehow check if another...
0
by: DBC User | last post by:
I am writing a program that I want it to run part of the features when run in our domain. Is there a way to check that using WindowsIdentity? I can use Name and take pharse and get the domain name....
2
by: Rick | last post by:
VB.Net 2005 I would like to programatically check the check box in a CheckedListBox control. I don't see any examples in the help and have not googled up anything either. How do I do this?
2
by: Shana | last post by:
#include<iostream.h> class Room { int length; int width; public: Room() {} Room(int l,int w=0) : width(w),length(l)
5
by: lovecreatesbea... | last post by:
The condition at line 31 is added to check if the program finished to read the whole file. Is it needed and correct? Thank you. #include <fstream> #include <iostream> #include <string> using...
1
by: =?Utf-8?B?WWFlbA==?= | last post by:
Hi, How can I check from C# code if outlook program if the process is already running? if not, I run outlook with: System.Diagnostics.Process.Start("OUTLOOK.EXE"); Thank you!
5
by: isabelle | last post by:
Hello... How are you every body? I want from you to check this program.. ************************************************** Suppose that the file inData.txt contains the following data:...
7
KoreyAusTex
by: KoreyAusTex | last post by:
I am having a very hard time making this program work right, I am sort of lost and I was wondering if I might get some advice. This is what I have so far but I have a rounding error when I use the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.