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
Mariulka [41]
4 years ago
13

Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binar

y. For an integer x, the algorithm is: As long as x is greater than 0 Output x % 2 (remainder is either 0 or 1) x
Computers and Technology
1 answer:
mylen [45]4 years ago
3 0

Answer:

The program to this question can be described as follows:

Program:

num= int(input('Enter a number: ')) #input value by user

st = '' #defining string variable

while num > 0: #define loop to calculte values binary number

   val= num % 2 # holding remainder (0 or 1) in val variable

   st =st+str(val) # store value in str variable

   num = num//2 #calculte quotient value

print("binary number is: ",st)

Output:

Enter a number: 5

binary number is:  101

Explanation:

Program description as follows:

Firstly the "num" variable is declared, for user input, then an "st" variable is declared, to calculates user input value binary number.

In the next step, a while loop is declared, inside the loop, another variable "Val" is declared, that holds value remainders, which is added on the "st" variable.

Outside the loop, the print method is used, that prints st variable holds value.

You might be interested in
Time management is the ability to use time effectively.
denis-greek [22]

Answer:

True

Explanation:

if you are able to manage time well, then that means you have good time management skills

3 0
3 years ago
Read 2 more answers
Help ASAP please This is a skills lab simulation for college, it’s on Microsoft word is there a keyboard shortcut or something o
nataly862011 [7]

Answer:

down right corner

Explanation:

next to the time

8 0
3 years ago
In Microsoft Access, what happens when you save a query once and run it but then add more to the query? What will happen? a)erro
Usimov [2.4K]
D)When the query is run again, the data that meets the new criteria will be retrieved.
5 0
4 years ago
Am I going to ever go back to school?
Ronch [10]

Answer:

who knows

Explanation:

5 0
3 years ago
Read 2 more answers
Write a class called Product. The class should have fields called name, amount, and price, holding the product’s name, the numbe
vichka [17]

Answer:

public class Product {

//Declaring the fields

   private String name;

   private int amount;

   private double price;

   //Constructor

   public Product(String name, int amount, double price) {

       this.name = name;

       this.amount = amount;

       this.price = price;

   }

   // The method get_price

   public double get_price(int amount){

       // amount of goods less than 10

       if(amount<10){

           double zeroDiscPrice;

           zeroDiscPrice = this.price;

           return zeroDiscPrice;

       }

       // amount of goods less than 100

       else if(amount>=10 && amount<100){

           double tenPercentDiscPrice;

           tenPercentDiscPrice = this.price-(this.price*0.1);

           return tenPercentDiscPrice;

       }

       // amount of goods greater than 100

       else{

           double twentyPercentDiscPrice;

           twentyPercentDiscPrice = this.price-(this.price*0.2);

           return twentyPercentDiscPrice;

       }

   }

}

Explanation:

The class is implemented in Java programming language

Three member variables (fields) are declared as described in the question

A constructor is created to initialize an instance of the class

The method get_price() as created uses a combination of if...else if....else To determing the price based on the amount of items bought as described in the question.

5 0
3 years ago
Other questions:
  • Which process refers to starting up a computer?
    15·2 answers
  • If Peyton Manning, a professional football player, wanted to remember his 16-digit credit card number, which of the following me
    5·1 answer
  • Given two variables hasToner and hasPaper of type bool, that have been declared and given values, write a code block that will o
    15·1 answer
  • Which function will add a grade to a student's list of grades in Python? add() append() print() sort()
    5·2 answers
  • In what order does the air flow in a canister vacuum cleaner pass through the following components?
    11·1 answer
  • __________ intelligence is an approach to boundary spanning which results from using sophisticated software to search through in
    15·1 answer
  • What types of storage can be used to access your data on another computer
    5·1 answer
  • Line installers must complete a four-year university degree program in order to be hired.
    5·2 answers
  • I have put the question in twice and I cannot get a answer for it .. this site isn’t great in my view..
    9·1 answer
  • . Which of the following refers to the informal rules for how to behave online? A.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!