Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9186891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:38:26+00:00 2026-06-17T19:38:26+00:00

Im doing a project that stimulate the ATM in C++ and having some troubles

  • 0

Im doing a project that stimulate the ATM in C++ and having some troubles with the accumulators, my question is: I am use switch (here is case 1) to change the values of 2 variables which are declared inside the function that contains the switch(), however the values only change inside case 1 and they reset themselves to the original value (like const declaration), so when I try to print the checking and saving (in case 3 and 4) it prints out the original amount (1000). So I dont know what I did wrong here. Problem is not with the amount, I have tried replacing amount with a numeric value but still doesnt work.
Please help

int transactions()
{   
    double checking = 1000.00, saving = 1000.00;
    double amount;
    switch (inputRange(menu()))
    {
    case 1: system("cls");
            amount = getAmount("Enter an amount to transfer from checking to saving: ");
            checking -= amount; 
            saving += amount;
            cout << checking << " " << saving; // they only change inside case 1
            cout << "\nTransaction completed! \n\nPress ENTER to return to main menu...";
            cin.ignore(99,'\n');
            break;

updates*** I already got it guys, thanks, just forgot about the &, this works

   int transactions(double &checkBal, double &saveBal)
{       
    double amount;

    //set precision
    cout << fixed << showpoint << setprecision(2);

    switch (inputRange(menu()))
    {
    case 1: system("cls");
            checkingToSaving (getAmount("Enter an amount to transfer from checking to saving: "), checkBal, saveBal);
            cout << "\nTransaction completed! \n\nPress ENTER to return to main menu...";
            cin.ignore(99,'\n');
            break;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:38:28+00:00Added an answer on June 17, 2026 at 7:38 pm

    The issue is that checking and saving only exist for the duration of a single call to transactions().

    They spring into existence when transactions() is called, get initialized, your code changes them, and they disappear the moment transactions() returns. When the function is called again, the whole cycle repeats.

    The two variables need to exist outside the function (probably as data members of some class).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing a project that use image processing techniques to identify different objects and
I'm working on a for-fun-project that I will be doing some calculations with and
I'm doing a project that involves speech recognition. But here i don't just need
I'm doing some research for a project that I might be doing soon, and
I am doing a project that recognize human face from camera. Here is the
I'm doing a project right now that might use a markup framework that I'll
Currently am doing project on Family Business. In that I need some video calling
I'm doing a project that spawn some hundreds of threads. All these threads are
I am doing some URL redirections in a project that I am currently working
I'm doing a project that involves solving some NP-hard graph problems. Specifically triangulation of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.