Answer:
yho
Explanation:
hayi no ntwana.... lala boy
2.13 LAB: Branches: Leap Year
A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the
difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The
requirements for a given year to be a leap year are:
1) The year must be divisible by 4
2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400
Some example leap years are 1600, 1712 and 2016.
Write a program that takes in a year and determines whether that year is a leap year.
Ex If the input is
1712
the output is
1712 13 leap year.
Ex If the nouts
1913
the outoutis
1913 not leap year.
Written is Coral Language
Answer:
integer userInput
userInput = Get next input
if userInput % 400 == 0
Put userInput to output
Put " is a leap year" to output
else
if userInput % 4 == 0
Put userInput to output
Put " is a leap year" to output
else
Put userInput to output
Put " is not a leap year" to output
Explanation:
I don't know what is so special about Coral but here we go. I couldn't find and IDE that supported Coral so I just used their Coral simulator on their website. The first if statement on line 5 determines if the number is divisible by 400. If so, the leap year is on a century year e.g 1900 1800. If not, the else statement will be executed and the second if statement will execute. If the number is divisible by 4, it is a leap year. If not, the else statement gets executed in which case the number was not a century leap year or a leap year. After that the program terminates.
Hope this helped :) If it didn't let me know and I do my best to find out what went wrong.
Have a good day :)
Write a program that repeatedly accepts as input a string of ACGT triples and produces a list of the triples and the corresponding amino acids, one set per line. The program will continue to accept input until the user just presses ENTER without entering any DNA codes.
Answer:
Explanation:
The following code is written in Python. I created a dictionary with all the possible gene combinations and their corresponding amino acids. The user then enters a string. The string is split into triples and checked against the dictionary. If a value exists the gene and amino acid is printed, otherwise an "Invalid Sequence" error is printed for that triple. The program has been tested and the output can be seen in the attached image below.
def printAminoAcids():
data = {
'TTT': 'Phe', 'TCT': 'Ser', 'TGT': 'Cys', 'TAT': 'Tyr',
'TTC': 'Phe', 'TCC': 'Ser', 'TGC': 'Cys', 'TAC': 'Tyr',
'TTG': 'Leu', 'TCG': 'Ser', 'TGG': 'Trp', 'TAG': '***',
'TTA': 'Leu', 'TCA': 'Ser', 'TGA': '***', 'TAA': '***',
'CTT': 'Leu', 'CCT': 'Pro', 'CGT': 'Arg', 'CAT': 'His',
'CTC': 'Leu', 'CCC': 'Pro', 'CGC': 'Arg', 'CAC': 'His',
'CTG': 'Leu', 'CCG': 'Pro', 'CGG': 'Arg', 'CAG': 'Gln',
'CTA': 'Leu', 'CCA': 'Pro', 'CGA': 'Arg', 'CAA': 'Gln',
'GTT': 'Val', 'GCT': 'Ala', 'GGT': 'Gly', 'GAT': 'Asp',
'GTC': 'Val', 'GCC': 'Ala', 'GGC': 'Gly', 'GAC': 'Asp',
'GTG': 'Val', 'GCG': 'Ala', 'GGG': 'Gly', 'GAG': 'Glu',
'GTA': 'Val', 'GCA': 'Ala', 'GGA': 'Gly', 'GAA': 'Glu',
'ATT': 'Ile', 'ACT': 'Thr', 'AGT': 'Ser', 'AAT': 'Asn',
'ATC': 'Ile', 'ACC': 'Thr', 'AGC': 'Ser', 'AAC': 'Asn',
'ATG': 'Met', 'ACG': 'Thr', 'AGG': 'Arg', 'AAG': 'Lys',
'ATA': 'Ile', 'ACA': 'Thr', 'AGA': 'Arg', 'AAA': 'Lys'
}
string = input("Enter Sequence or just click Enter to quit: ")
sequence_list = []
count = 0
gene = ""
for x in range(len(string)):
if count < 3:
gene += string[x]
count += 1
else:
sequence_list.append(gene)
gene = ""
gene += string[x]
count = 1
sequence_list.append(gene)
for gene in sequence_list:
if gene.upper() in data:
print(str(gene.upper()) + ": " + str(data[gene.upper()]))
else:
print(str(gene.upper()) + ": invalid sequence")
printAminoAcids()
Write an algorithm to solve general formula?
Answer:
2+2=4
Explanation:
simple math cause of that bubye
Compute the acceleration of gravity for a given distance from the earth's center, distCenter, assigning the result to accelGravity. The expression for the acceleration of gravity is: (G * M) / (d2), where G is the gravitational constant 6.673 x 10-11, M is the mass of the earth 5.98 x 1024 (in kg) and d is the distance in meters from the earth's center (stored in variable distCenter).
#include
using namespace std;
int main() {
double G = 6.673e-11;
double M = 5.98e24;
double accelGravity;
double distCenter;
cin >> distCenter;
/* Your solution goes here */
cout << accelGravity << endl;
return 0;
}
Answer:
Replace /* Your solution goes here */ with the following expression
accelGravity = (G * M) / (distCenter *distCenter );
Explanation:
Required
Complete the code
The equivalent expression of (G * M) / (d^2) is:
(G * M) / (distCenter *distCenter );
The expression must be stored in accelGravity.
So, we have:
accelGravity = (G * M) / (distCenter *distCenter );
Write a program that reads a list of 10 integers, and outputs those integers in reverse. For coding simplicity, follow each output integer by a space, including the last one. Then, output a newline. coral
def reverse_list (num_list):
try:
if num_list.isdigit() == True:
return num_list[::-1]
elif num_list < 0:
return "Negative numbers aren't allowed!"
except ValueError:
return "Invalid input!"
user_list = list (int (input ("Please enter ten random positive numbers: " )))
print (reverse_list (user_list))
3. Using Assume the following list of keys: 36, 55, 89, 95, 65, 75, 13, 62, 86, 9, 23, 74, 2, 100, 98 This list is to be sorted using the quick sort algorithm as discussed in this chapter. Use pivot as the middle element of the list. a. Give the resulting list after one call to the function partition. b. What is the size of the list that the function partition partitioned
Answer:
a. 36, 55, 13, 9, 23, 2, 62, 86, 95, 65,74, 75, 100, 98, 89
b. 15
Explanation:
Qla
What are the activities a Database Designer will do if using the SDLC to design a Database [10]
Q1b
List the five main components of Access Database and state their uses [10]
Answer:a
What are the activities a Database Designer will do if using the SDLC to design a Database [10]
Q1b
List the five main components of Access Database and state their uses [1
Explanation:
During the data transmission there are chances that the data bits in the frame might get corrupted. This will require the sender to re-transmit the frame and hence it will increase the re-transmission overhead. By considering the scenarios given below, you have to choose whether the packets should be encapsulated in a single frame or multiple frames in order to minimize the re-transmission overhead.
Justify your answer with one valid reason for both the scenarios given below.
Scenario A: Suppose you are using a network which is very prone to errors.
Scenario B: Suppose you are using a network with high reliability and accuracy.
The packets would be encapsulated in single frame in scenario A. In scenario B, it should be in multi frames.
In scenario A, given that this network has been said to be prone to error, the packets should be encapsulated in single frames.
The reason for this is because, using a single frame helps to decrease error. We have been told already that it is prone to error. If you use the multi frame, there would be very high likelihood of errors occurring.
In scenario B, given that the network is accurate and very reliable, the best packet is the multi frame.
It would give a quicker transmission and the likelihood of errors occurring is also low.
Read more on https://brainly.com/question/24373056?referrer=searchResults
You are consulting with another medium sized business regarding a new database they want to create. They currently have multiple normalized source databases that need consolidation for reporting and analytics. What type of database would you recommend and why
Answer:
The enormous amount of data and information that a company generates and consumes today can become an organizational and logistical nightmare. Storing data, integrating it and protecting it, so that it can be accessed in a fluid, fast and remote way, is one of the fundamental pillars for the successful management of any company, both for productive reasons and for being able to manage and give an effective response to the customers.
Good big data management is key to compete in a globalized market. With employees, suppliers and customers physically spread across different cities and countries, the better the data is handled in an organization, the greater its ability to react to market demand and its competitors.
Databases are nowadays an indispensable pillar to manage all the information handled by an organization that wants to be competitive. However, at a certain point of development in a company, when growth is sustained and the objective is expansion, the doubt faced by many managers and system administrators is whether they should continue to use a database system, or if they should consider the leap to a data warehouse. When is the right time to move from one data storage system to another?
Which of these is a tool for creating mobile apps?
Appy Pie
C#
Apple Pie
C++
Answer:
C++
Explanation:
C++ is used in application development
Microsoft office can be classified under what heading of application
Answer:
Word processing software/application
pls mark as brainliest!
Have a grt day!!!
If your organization hires a new employee, what would you do to create a user account in the Linux system and add the account to a group? What commands would you use? What configuration files would you check and modify?
Following are the responses to this question:
The user account is "olivia".In the Linux system to see the account go to the "/home directory".For the configuration file we use ".bash_logout , .bash_profile, and .bashrc" files.Creating users:
We will use the useradd command to achieve this. Using that same command, you can create users who would log in or customers who would log in (in the case of creating a user for a software installation).
In its basic form, the command is as follows:
[Options] useradd usernameTake this user olivia, for instance. Assuming that you had been to issue the command prompt:
olivia has become a user.Users are added to the system without the need for a home directory and are unable to log on. It if we were using this rather than running the command without arguments?
sudo using useradd -m oliviaUsing the command above, a new user would be created, including a home directory that corresponded to the username. That means that you might now see the name "olivia" in the directory "/home".
But what about the lockout concern that was raised earlier? Both these methods are possible. After creating the user, you can enter the following command:
Password for olivia is: sudo passwd oliviaYou'll be requested to enter & verify your new password once you've completed the process. This unlocks the user profile, allowing them to log in.
This command might look like if you wanted to accomplish it in one go:
sudo useradd -m olivia -p PASSWORDYou should be using Passcodes as the login for the user olivia.
As soon as the user logs in, he or she can update their account password by using the password command to input their current password, and afterward entering/verifying their new one.
To create a user that has no personal account and cannot log in, execute the following instructions:
sudo use useradd as the-M USERNAME sudo use usermod as the -L USERNAMEThe user to be added is identified by USERNAME.
It establishes a user with really no root folder and prevents them from signing in with a second operation.
To add an existing user to a group on Linux, follow the instructions:
As root, log in to your accountUse the useradd instruction to add a new user (for example, useradd roman)If you'd like to log on as a new customer, type su plus that user's name.Entering the word "exit" will logout you from your account.Another way to add a user to a group under Linux would be to use the following syntax:
Alternatively, you can use the usermod command.The name of the club should be substituted for example group in this sentence.Example username should be replaced with the name of the user you'd like added.The following operations are performed when a new login is added to the system.
The user's home directory (/home/username by default) is now created.To set configuration files for the user's session, the following secret files are copied into another user's home directory..bash_logout
.bash_profile
.bashrc
/var/spool/mail/username includes the user's mail spool.The new user account is arranged in groups with the same name.Learn more:
Linux system: brainly.com/question/13843535
what is
computer.write its example
what is the build in libary function to compare two strings?
Answer:
strcmp() is a built-in library function and is declared in <string. h> header file. This function takes two strings as arguments and compare these two strings lexicographically.
Explanation:
Hope it helps
A life insurance salesperson who takes advantage of the foot-in-the-door phenomenon would be most likely to:________
a. emphasize that his company is one of the largest in the insurance industry.
b. promise a free gift to those who agree to purchase an insurance policy.
c. address customers by their first names.
d. ask customers to respond to a brief survey of their attitudes regarding life insurance.
Answer:
d. ask customers to respond to a brief survey of their attitudes regarding life insurance.
Explanation:
A life insurance policy can be defined as a contract between a policyholder and an insurer, in which the insurer agrees to pay an amount of money to a specific beneficiary either upon the death of the insured person (decedent) or after a set period of time.
A salesperson (sales representative) refers to an individual or employee who is saddled with the responsibility of taking orders from customers, as well as selling finished goods and services to consumers or end users.
A foot-in-the-door phenomenon can be defined as a compliance (persuasive) technique or tactics that assumes a person agreeing to perform a small request increases the likelihood of he or she agreeing to a subsequent larger request. Thus, it posits that when a person agrees to a small, it makes it difficult for him or her to decline a second, larger (bigger) request.
In this context, a life insurance salesperson who takes advantage of the foot-in-the-door phenomenon would most likely ask his or her customers to respond to a brief survey of their attitudes regarding life insurance.
tinh S(n) = 1+2+3+.....+n
Answer:
-1/12
Explanation:
[tex]\sum_{k=0}^{k=n} k = \frac{n(n+1)}{2}\\[/tex]
look up the derivation by Srinivasa Ramanujan for a formal proof.
What is the relationship between an organization’s specific architecture development process and the Six-Step Process?
Answer:
It is a method of developing architecture in various stages
Explanation:
The organization-specific architecture developmental process is a tested and repeated process for developing architecture. It made to deal with most of the systems. It describes the initial phases of development. While the six step process is to define the desired outcomes, Endorse the process, establish the criteria and develop alternatives. Finally to document and evaluate the process.If Scheme were a pure functional language, could it include DISPLAY ? Why or why not?
Answer:
When Scheme is a pure functional language, it cannot include the function DISPLAY. Since the pure functional languages will return the same value whenever the same expression is evaluated, and the DISPLAY would be the output and thus it cannot be part of the purely functional language. Thus in the pure functional language we can evaluate the expressions with the same arguments and it returns the same value since there is no state to change.
Explanation:
c)what formula would be in the cell E2
Excel will generally be able to handle any properly-input mathematical formula, if valid operators are used. Commonly used operators include "+" (addition), "-" (subtraction), "*" (multiplication) and "/" (division). (Microsoft has a complete list of valid operators to be used in Excel formulas on the Office website). Here are some examples of formulas using common operators:
Formula Description
=C2-B2 Subtracts contents of B2 from contents of C2
=C2/B2 Divides contents of C2 by contents of B2
=(B2+C2+D2)/3 Adds contents of B2, C2, and D2 and divides result by 3
After hitting "Enter", the cell will display the calculated value, while the formula bar will still display the formula. (Note: Always hit “Enter” when finished entering a formula, manually. If you click off the cell, the cell you click to will be added to your formula.)Formulas
Formulas in Excel are basically mathematical expressions that use cell references (e.g., “A5”,” D17”) as arguments. For example, a formula that adds the contents of cell E5 and E6 could be written as follows:
= E5+E6
(Note: all formulas in Excel need to be preceded by an “=” sign.) If the values contained in E5 and E6 are 6 and 11, respectively, the formula will produce 17 as the value it displays. If you change E5 to 7, the result will automatically change to 18.
Example
Let's say you were putting together an office supply order, and you wanted to keep track of much you were spending. You could put together a spreadsheet like the one below, with the list of items to be purchased, their unit prices, the number of each item ordered, and the total spent for each. It would make sense to enter the things you know in advance (like the price of individual items and the number ordered), but you could let Excel calculate the totals for you. For the first item listed below (pencils), this could be done by making the value of the total price (cell D2), the value of the unit price (held in cell C2) multiplied by the number of items ordered (held in D2). This formula would be written "=B2*C2".
Once you click "OK", your completed formula will be input into the cell.
Copying and pasting formulas
Often, you will need Excel to do a series of similar computations, where the only things that will change are the cells used as arguments. For instance, in the example above, you would probably like Excel to calculate the Total Price for each item in the order. You could re-input the same formula used to get the total price for pencils in each cell in that row, just changing the cells referenced (i.e. "=PRODUCT(B3:C3)", "=PRODUCT(B4:C4)", etc.), but Excel has simpler method for this. If you have multiple cells in the same row or column that need to do the same computation, you can simply copy the value in the cell you entered a formula, and then paste it into the subsequent cells. Excel will then automatically adjust which cells are included in the formula, based upon which cell the formula was pasted to. So, if the original formula entered in D2 was "=PRODUCT(B2:C2)", the formula pasted into D4 would be "=PRODUCT(B4:C4)"
More simply, if you have a formula you want repeated in a number of directly adjoining cells, you can just click and drag the bottom right corner of the cell with the original formula (see image below) onto the cells you want the same formula entered, and Excel will automatically copy and paste the formula for you, with appropriate adjustments made to the cell numbers in the formula.
After selecting "PRODUCT" and clicking OK, you will get another dialog box, that allows you to select the cells to be multiplied. You can do this for individual cells, by selecting cells separately in the "Number1" and "Number2" boxes shown below, or by selecting an array of cells, by clicking and dragging on the range cells you want to use on the spreadsheet, itself. (Note: if you try to enter a formula in a cell using the Insert Formula button and there are adjacent cells with numbers, Excel will often select those cells automatically, so make sure the cells selected in the dialog box are the correct ones.) Excel also has built-in functions that can do a lot of useful calculations. These are most easily accessed by hitting the Insert Function button, which is represented by the “fx” symbol next to the formula bar. For example, instead of entering the formula shown above, the same result could have been achieved using the built-in "PRODUCT" function by clicking in cell D2 and hitting the Insert Formula button. This would give a dialog box like the one shown, below.
After choosing “PRODUCT” and pressing OK, a new dialogue box will appear where you may choose which cells should be multiplied. By selecting particular cells in the “Number1” and “Number2” boxes as shown below, you can do this for specific cells.
What is the formula would be in the cell E2Additionally, Excel contains many useful built-in functions that can perform calculations. The button shown by the “fx” sign next to the formula bar, “Insert Function,” can be used to access these the simplest way by clicking it.
Make sure the cells selected in the dialogue box are the proper ones because if you try to insert a formula in a cell using the Insert Formula button and there are adjacent cells containing numbers. Excel will frequently select those cells automatically.)
Therefore, by deciding a range of cells on the spreadsheet itself by clicking and dragging on the desired range of cells.
Learn more about cell E2 here:
https://brainly.com/question/6961706
#SPJ2
cloud offers better protection compare to on premise?
Why is cloud better than on-premise? Dubbed better than on-premise due to its flexibility, reliability and security, cloud removes the hassle of maintaining and updating systems, allowing you to invest your time, money and resources into fulfilling your core business strategies.
The security of the cloud vs. on-premises is a key consideration in this debate. Cloud security controls have historically been considered less robust than onprem ones, but cloud computing is no longer a new technology. . A company running its own on-premises servers retains more complete control over security.
Believe it!!
Pls follow me.
a do-while loop that continues to prompt a user to enter a number less than 100, until the entered number is actually less than 100. End each prompt with newline Ex: For the user input 123, 395, 25, the expected output is:Enter a number (<100):Enter a number (<100):Enter a number (<100):Your number < 100 is: 25
Answer:
Explanation:
import java.util.Scanner;
//Declare the class NumberPrompt.
public class NumberPrompt
{
public static void main(String args[])
{
/*Declare the variable of scanner class and allocate the
memory.*/
Scanner scnr = new Scanner(System.in);
//Initialize the variable userInput.
int userInput = 0;
/* Your solution goes here*/
//Start the do-while loop
do
{
//Prompt the user to enter the number.
System.out.println("Enter a number(<100)");
/*Store the number entered by the user in the
variable userInput.*/
userInput=scnr.nextInt();
}while(userInput>=100);/*Run the do-while loop till the
user input is greater than 100*/
//Print the number which is less than 100.
System.out.println("Your number <100 is "+userInput);
return;
}
}
Output:-
Define firewall ?with example
Explanation:
it acts as a barrier between a trusted system or network and outside connections, such as the Internet. However, a computer firewall is more of a filter than a wall, allowing trusted data to flow through it. ... For example, a basic firewall may allow traffic from all IP.
if my answer helps you than mark me as brainliest.
Answer:
hope this helps
Explanation:
Firewalls are software or hardware that work as a filtration system for the data attempting to enter your computer or network. Firewalls scan packets for malicious code or attack vectors that have already been identified as established threats.And also firewall is a network security device that monitors incoming and outgoing network traffic and permits or blocks data packets based on a set of security rules.
with the aid of examples explain the differences between open source software and licensed software
Answer:
Explanation:
Source is when a company go no limits to run the software but can easily be taken done by a complaint or two or a bug while a licensed it a protected version of the software.
Write a program that uses linear recursion to generate a copy of an original collection in which the copy contains duplicates of every item in the original collection. Using linear recursion, implement a function that takes a list as user-supplied runtime input and returns a copy of it in which every list item has been duplicated. Given an empty list the function returns the base case of an empty list.
Answer: b
Explanation:
Program using linear recursion to duplicate items in a list:
def duplicate_list(lst):
if not lst:
return []
else:
return [lst[0], lst[0]] + duplicate_list(lst[1:])
# Example usage
user_input = input("Enter a list of items: ").split()
original_list = [item for item in user_input]
duplicated_list = duplicate_list(original_list)
print("Duplicated list:", duplicated_list)
How can a program use linear recursion to duplicate items in a list?By implementing a function that utilizes linear recursion, we can create a copy of an original list with duplicated items. The function duplicate_list takes a list lst as input and checks if it is empty. If the list is empty, it returns an empty list as the base case.
Otherwise, it combines the first item of the list with itself and recursively calls the function with the remaining items (lst[1:]). The duplicated items are added to the resulting list. This process continues until all items in the original list have been duplicated and the duplicated list is returned.
Read more about linear recursion
brainly.com/question/31313045
#SPJ2
A hierarchy chart can be helpful for a. planning the functions of a program b. naming the functions of a program c. showing how the functions of a program relate to each other d. all of the above e. a and c only
Answer:
Hence the correct options are option B and option C.
Explanation:
Hierarchy Chart means top to bottom structure 0f a function or a program or an organization.
Planning the functions of a program means deciding beforehand that what are the functions of a program and what to try to do and when to try to, hierarchy Charts are often helpful In doing/knowing this all.
Showing how the functions of a program relate to every other means what's the connection between two functions for instance if we have a hierarchical chart of a corporation member then we'll have the connection among the members of the team i.e., first, we'll have CEO, then Manager then team/ project lead then team members and by using hierarchical chart ready to " we will be able to identify the connection among them. during a similar way, we will have a relationship among the functions of a program using the hierarchical chart.
Outlook 365 can be described as a personal information manager.
True or false
Answer:
True
Explanation:
The statement is True. The Microsoft Outlook 365 can be described as personal information manager.
What is Microsoft Outlook?Microsoft Outlook is the software system, that allows the users to manage various personal and official information and data altogether at one place.
The Microsoft Outlook is known as personal information manager because it allows the users to managing task, providing calendar services, helps in emailing. It also manages contact and keeps the record of journal logs and many more.
Therefore, the statement regarding outlook 365 is True.
Learn more about Microsoft Outlook, here:
https://brainly.com/question/17457799
#SPJ5
Research via the internet and find an article in the news regarding wireless hacking, hardware hacking, or other security breach. As security and IT changed so rapidly, your article should be no older than 2007 (i.e. Less than 5 years old). Summarize the article using at least 500 words.
Hi, I provided some explanation of key terms.
Explanation:
Wireless hacking: basically the term refers to any unethical activity carried over a radio wave-connected network (eg Internet or Wifi connection) that would provide unauthorized access to information.
Hardware hacking: On the other hand, hardware hacking involves resetting physical hardware with the objective of using it in a way not originally intended by the manufacturer.
Why use LinkedIn automation for LinkedIn?
Answer:
Using LinkedIn automation tools to run successful outreach campaigns has become popular. It’s because these tools automate tedious networking tasks such as visiting profiles, collecting data, sending out bulk connection requests, messages, and follow-ups, etc.
With the help of the latest LinkedIn automation tools, you can quickly perform all the repetitive tasks while saving yourself a lot of time that you can use on actual relationship building and lead nurturing tasks.
However, LinkedIn isn’t really amused when using any bots or automation tools for LinkedIn.
An engineer is designing an HTML page and wants to specify a title for the browser tab to display, along with some meta data on what tools the page should use. These items would best fit in which of the following sections
a. The element
b. The element
c. The
element
d. The
An HTML is made up of several individual tags and elements such as the head, body. form, frame and many more.
In an HTML page, the meta element and the title element are placed in the head element.
An illustration is as follows:
< head >
< title > My Title < /title >
< meta charset="UTF-8" >
< / head >
The head element contains quite a number of elements and tags; some of them are:
metatitle stylescriptbaseAnd so on.
Hence, in order to use a meta-data element, the meta element has to be placed within the head element.
Read more about HTML elements at:
https://brainly.com/question/4484498
Suppose we can buy a chocolate bar from the vending machine for $1 each. Inside every chocolate bar is a coupon. We can redeem six coupons for one chocolate bar from the machine. This means that once you have started buying chocolate bars from the machine, you always have some coupons. We would like to know how many chocolate bars can be eaten if we start with N dollars and always redeem coupons if we have enough for an additional chocolate bar.For example, with 6 dollars we could consume 7 chocolate bars after purchasing 6 bars giving us 6 coupons and then redeeming the 6 coupons for one bar. This would leave us with one extra coupon. For 11 dollars, we could consume 13 chocolate bars and still have one coupon left. For 2 dollars, we could have consumed 14 chocolate bars and have two coupons left.Write a program that inputs a value for N and outputs how many chocolate bars we can eat and how many coupons we would have left over. Use a loop that continues to redeem coupons as long as there are enough to get at least one chocolate bar.
Answer and Explanation:
Using JavaScript:
/* program should take N input which represents the dollar amount and output how many chocolate bars and how many coupons we have*/
function chocolatebar(dollars){
var dollaramt= dollars;
var i;
for(i=0; i <= dollaramt; i++){
i=i+6
?
Alert ("you have 1 extra chocolate bar");
:
Alert ("keep buying chocolate bars to get more coupons for a bonus chocolate bar")
}
}
*