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
Svetlanka [38]
3 years ago
11

When possible, you should avoid using _________ variables in a program?

Computers and Technology
1 answer:
dalvyx [7]3 years ago
4 0

Answer:

Global variable

Explanation:

You should avoid using global variables in a program because global variables can be accessed by any part of the code  and every function or any part of the code has the tendency to alter or modify its value. One can't limit the scope or in other words one cant simply force any part of the program not to use them or  modify it's values. Testing of large programs also becomes difficult as it is hard to keep track of the functions reading and modifying the values of global variables

You might be interested in
write an application to presell a limited number of cinema tickets. each buyer can buy as many as 4 tickets. No more than 100 ti
Rus_ich [418]

Answer:

The program for this question can be given as:

Program:

import java.util.*;  //import package

public class TicketSeller  //define class

{

public static void main(String ar[])  //main method

{

int totalTickets=100,userCount=0,remainingTickets=100,numTickets; // varaibale

try           //try block

{

Scanner ob= new Scanner(System.in);  //input by user

System.out.println("Total Tickets:"+totalTickets);

while(remainingTickets!=0)          //loop

{

System.out.print("Enter no of Tickets to buy:");      //message.

numTickets=ob.nextInt(); //taking input

if(numTickets<=4)         //conditional statements.

{

if(remainingTickets>=numTickets)

{

remainingTickets=remainingTickets-numTickets;              //calculate remainingTickets

userCount++;

System.out.println("remaining tickets : "+remainingTickets+" user :"+userCount);      

}

else

{

System.out.println("Invalid Input");

}

}

else

{

System.out.println("Invalid Input");

}

}

}

catch(Exception e)            //catch block.

{

}

}

}

Output:

Total tickets:100

Enter no of Tickets to buy: 4

Remaining tickets : 96 User :1

Enter no of Tickets to buy: 4

Remaining tickets : 92 User :2

Enter no of Tickets to buy: 4

Remaining tickets : 88 User :3

.

.

.

Enter no of Tickets to buy: 4

Remaining tickets : 0 User :25

Explanation:

In the above Program firstly we import the package for the user input. Then we declare the class that is (TicketSeller) given in question. In this class we declare the main method in the main method we declare the variable that is totalTickets, userCount, remainingTickets and numTickets .Then we use the exception handling. we use this for providing the validation from the user side that users don't insert value less the 4. In the exception handling, we use the multiple catch block with try block. Then we input from the user and calculate the values and in the last, we print all the values.

8 0
3 years ago
Give ways on how to effectively save.​
sp2606 [1]

Answer:

Explanation:

say goodbye to debt. Monthly debt payments are the biggest money suck when it comes to saving. ...

Cut down on groceries. ...

Cancel automatic subscriptions and memberships.

4 0
3 years ago
Outside of a C program, a file is identified by its ________while inside a C program, a file is identified by a(n) ________. fil
Alexxandr [17]

Answer: name, file stream object

Explanation:

4 0
2 years ago
Write a program that reads in an array of type int . you may assume that there are fewer than 50 entries in the array. your prog
Alla [95]
This may be a difficult thing to do so for anyone to ACTUALLY answer this you migghttt want to up the amount of points you get for answering maybe, 20-40 points.
7 0
3 years ago
What is star topology
Alexxx [7]
Every node connects to a central network device. like a hub, switch, or computer.
4 0
3 years ago
Read 2 more answers
Other questions:
  • How does applying Fontworks effects to text on an advertising flyer change the text?
    8·1 answer
  • What does media saturation mean?
    15·1 answer
  • WILL DO A BRIANLY! Use an algorithm to help the Python Turtle get to the finish line in 10 steps by using only the 3 commands be
    12·1 answer
  • What is thhe name of service included with windows server operating systemthat manages a centralized database containing user ac
    5·1 answer
  • Which of the following is NOT a strength of monetary policy?
    15·1 answer
  • what is musical technology specifically, the origins of its genesis &amp; its importance to the baroque era
    6·1 answer
  • Describe two different examples of potential conflicts, and explain why these conflicts can have a negative impact on
    14·1 answer
  • What is the top 3 cloud provider in the world with statics or data including the example and reason(s).
    11·1 answer
  • ARGENT !!20 POINTS <br> А ________ translates commands from a computer to draw lines on paper.
    10·2 answers
  • PLEASE ANSWER! I NEED IN 30 MIN.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!