1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
klio [65]
2 years ago
14

Write a C++ function for the following:

Computers and Technology
1 answer:
Nana76 [90]2 years ago
4 0

Solution :

class Account

$ \{ $

public:

$\text{Account}()$;

double $\text{getBalance}$();

void $\text{setBalance}$();

$\text{bool withdraw}$(double bal);

$\text{private}:$

double $\text{balance}$;

}:

$\text{Account}()$ {}

double $\text{getBalance}$()

$ \{ $

$\text{return balance}$;

}

void $\text{setBalance}$(double $\text{balance}$)

$ \{ $

this.$\text{balance}$ = $\text{balance}$;

}

$\text{boolean}$ withdraw($\text{double bal}$)

$ \{ $

if($\text{balance}$ >= bal)

$ \{ $

$\text{balance}$ = $\text{balance}$ - bal;

$\text{return}$ true;

}

$\text{return}$ false;

}

}

You might be interested in
Which of the following is generally true about 401(k) and 403(b) retirement plans
Tanzania [10]
<span>- They're offered by the employers to the employees.
- They bring various tax benefit to you.
- They restrict you about when you can withdraw your money.</span>
3 0
2 years ago
How do new sources of power assist in the development of inventions?
pentagon [3]
<span>New sources of power assist in the development of inventions since t</span>he new inventions would have been worthless without a reliable source of power energy.
3 0
3 years ago
Write an algorithm and draw flowchart to print 30 terms in the following sequence
valina [46]

Answer:

/*

I don't know what language you're using, so I'll write it in javascript which is usually legible enough.

*/

console.log(buildSequence(30));

function buildSequence(maxVal){

   maxVal = Math.abs(maxVal);

   var n, list = [];

   for(n = 1; n < maxVal; n++){

       /*

        to check for odd numbers, we only need to know if the last bit

        is a 1 or 0:

       */

       if(n & 1){ // <-- note the binary &, as opposed to the logical &&

           list[list.length] = n;

       }else{

           list[list.length] = -n;

       }

   }

   return list.implode(',');

}

3 0
3 years ago
Write a python program to read four numbers (representing the four octets of an IP) and print the next five IP addresses. Be sur
sdas [7]

Answer:

first_octet = int(input("Enter the first octet: "))

second_octet = int(input("Enter the second octet: "))

third_octet = int(input("Enter the third octet: "))

forth_octet = int(input("Enter the forth octet: "))

octet_start = forth_octet + 1

octet_end = forth_octet + 6

if (1 <= first_octet <= 255) and (0 <= second_octet <= 255) and (0 <= third_octet <= 255) and (0 <= forth_octet <= 255):

   for ip in range(octet_start, octet_end):

       forth_octet = forth_octet + 1

       if forth_octet > 255:

           forth_octet = (forth_octet % 255) - 1

           third_octet = third_octet + 1

           if third_octet > 255:

               third_octet = (third_octet % 255) - 1

               second_octet = second_octet + 1

               if second_octet > 255:

                   second_octet = (second_octet % 255) - 1

                   first_octet = first_octet + 1

                   if first_octet > 255:

                       print("No more available IP!")

                       break

       print(str(first_octet) + "." + str(second_octet) + "." + str(third_octet) + "." + str(forth_octet))

else:

   print("Invalid input!")

Explanation:

- Ask the user for the octets

- Initialize the start and end points of the loop, since we will be printing next 5 IP range is set accordingly

- Check if the octets meet the restrictions

- Inside the loop, increase the forth octet by 1 on each iteration

- Check if octets reach the limit - 255, if they are greater than 255, calculate the mod and subtract 1. Then increase the previous octet by 1.

For example, if the input is: 1. 1. 20. 255, next ones will be:

1. 1. 21. 0

1. 1. 21. 1

1. 1. 21. 2

1. 1. 21. 3

1. 1. 21. 4

There is an exception for the first octet, if it reaches 255 and others also reach 255, this means there are no IP available.

- Print the result

8 0
3 years ago
If you insert a picture, resize and reposition it, and then change to a different picture, you must modify the new picture to
Mashcka [7]

Answer:

false , that is not true

Explanation:

because a person can change to a different picture , but it Is not by force it will have a match to the original

3 0
1 year ago
Read 2 more answers
Other questions:
  • How to write a program that prompts the user to input two POSITIVE numbers — a dividend (numerator) and a divisor (denominator).
    13·1 answer
  • Most keyboards today are in a
    8·1 answer
  • What is the sum of each pair of binary integers? (assuming 8-bit register is used)
    5·1 answer
  • Geobubble Chart (2D) displaying Robot Density Per 10,000 Employees for the specified countries;
    7·1 answer
  • Write a program that asks the user for two file names. The first file will be opened for input and the second file will be opene
    8·1 answer
  • Kiera is building a new computer and wants to make sure she has an adequate power supply for all the new equipment she is purcha
    15·2 answers
  • All mla text is double spaced. true false
    13·2 answers
  • Define<br>output<br>devices<br>.<br>Give<br>any<br>three<br>examples<br>.<br>3.​
    8·2 answers
  • Which of the following is a sample IPv4 address?
    14·1 answer
  • The advancements in which of the following technologies has most changed the American job market in recent years?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!