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
Genrish500 [490]
3 years ago
7

Write a program that reads in a list of numbers, and for each number, determines and prints out whether or not that number is ab

undant.
Computers and Technology
1 answer:
adelina 88 [10]3 years ago
7 0
int IsAbundant(int n)
{
int divisorSum = 0;
for (int i = 1; i < n; i++) {
 if ((n % i) == 0) {
  divisorSum += i;
 }
}
return divisorSum > n;
}


int main()
{
int number = 0;
do {
 printf("Enter a number (0 to quit): ");
 scanf_s("%d", &number);
 if (IsAbundant(number)) {
  printf("%d is abundant!\n", number);
   } else
   {
    printf("%d is not abundant.\n", number); }
   } while (number > 0);

   return 0;
}

You might be interested in
A curb of this color means you may stop only to pick up or drop offs passengers or male
Delicious77 [7]
I believe it is a white curb!
7 0
3 years ago
अस्स्मन्चचरे ------------------- दृश्यते |
Semmy [17]

Answer:

5?

Explanation:

4 0
3 years ago
A custom window shade designer charges a base fee of $50 per shade. In addition, charges are added for certain styles, sizes, an
jeka94

Answer:

Check the explanation

Explanation:

* Filename: ShadeDesigner.java

* Programmer: Jamin A. Bishop

* Date: 3/31/2012

* version 1.00 2012/4/2

*/

import java. awt.*;

import java. awt. event.*;

import java. text. DecimalFormat;

import javax. swing.*;

import javax. swing. event. ListSelectionEvent;

import javax. swing. event. ListSelectionListener;

public class ShadeDesigner extends JFrame

{

private String[] styles = {"Regular Shades", "Folding Shades", "Roman Shades"};

private String[] size = {"25 Inches Wide", "27 Inches Wide",

"32 Inches Wide", "40 Inches Wide"};

private String[] colors = {"Natural", "Blue", "Teal",

"Red", "Green"};

private JLabel banner;// To display a banner

private JPanel bannerPanel;// To hold the banner

private JPanel stylesPanel;//

private JPanel sizePanel;//

private JPanel colorPanel;

private JPanel buttonPanel;//

private JList stylesList;

private JList sizeList;

private JList colorList;

private JTextField Styles;

private JTextField Size;

private JTextField Color;

private JButton calcButton;

private JButton ExitButton;

private double totalCharges = 50.00;

//Constants

private final int ROWS = 5;

private final double regularCost = 0.00;//base price for the blinds

private final double foldingCost = 10.00;//extra cost for folding blinds

private final double romanCost = 15.00;//extra cost for roman blinds

private final double twentyfiveInCost = 0.00; //extra cost for 25" blinds

private final double twentySevenInCost = 2.00;//extra cost for 27" blinds

private final double thirtyTwoInCost = 4.00;//extra cost for 32" blinds

private final double fourtyInCost = 6.00;//extra cost for 40" blinds

private final double naturalColorCost = 5.00;//extra cost for color

public ShadeDesigner()

{

//display a title

setTitle("Shade Designer");

// Specify what happens when the close button is clicked.

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

// Create the banner on a panel and add it to the North region.

buildBannerPanel();

add(bannerPanel, BorderLayout. NORTH);

stylesPanel();

add(stylesPanel, BorderLayout. WEST);

sizePanel();

add(sizePanel, BorderLayout. CENTER);

colorPanel();

add(colorPanel, BorderLayout. EAST);

buttonPanel();

add(buttonPanel, BorderLayout. SOUTH);

pack();

setVisible(true);

}

//build the bannerpanel

private void buildBannerPanel()

{

bannerPanel = new JPanel();

bannerPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

banner = new JLabel("Shade Designer");

banner.setFont(new Font("SanSerif", Font.BOLD, 24));

bannerPanel.add(banner);

}

//stylepanel

private void stylesPanel()

{

JLabel styleTitle = new JLabel("Select a Style.");

stylesPanel = new JPanel();

stylesPanel. setBorder(BorderFactory. createEmptyBorder(5,5,5,5));

stylesList = new JList (styles);

stylesList.setVisibleRowCount(ROWS);

JScrollPane stylesScrollPane = new JScrollPane(stylesList);

stylesList. setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

stylesList. addListSelectionListener(new stylesListListener());

stylesPanel. setLayout(new BorderLayout());

stylesPanel. add(styleTitle, BorderLayout. NORTH);

stylesPanel. add(stylesScrollPane, BorderLayout. CENTER);

Styles = new JTextField (5);

Styles. setEditable(false);

//stylesPanel. add(StylesLabel, BorderLayout. CENTER);

stylesPanel. add(Styles, BorderLayout. SOUTH);

}

private class stylesListListener implements ListSelectionListener

{

public void valueChanged (ListSelectionEvent e)

{

String selection = (String) stylesList. getSelectedValue();

Styles. setText(selection);

}

}

//size panel

private void sizePanel()

{

JLabel sizeTitle = new JLabel("Select a Size.");

sizePanel = new JPanel();

sizePanel. setBorder(BorderFactory. createEmptyBorder(5,5,5,5));

sizeList = new JList (size);

sizeList.setVisibleRowCount(ROWS);

JScrollPane stylesScrollPane = new JScrollPane(sizeList);

sizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

sizeList.addListSelectionListener(new sizeListListener());

sizePanel. setLayout(new BorderLayout());

sizePanel. add(sizeTitle, BorderLayout. NORTH);

sizePanel. add(stylesScrollPane, BorderLayout. CENTER);

//sizeLabel = new JLabel("Style Selected: ");

Size = new JTextField (5);

Size.setEditable(false);

//stylesPanel. add(StylesLabel, BorderLayout. CENTER);

sizePanel. add(Size, BorderLayout. SOUTH);

}

private class sizeListListener implements ListSelectionListener

{

public void valueChanged (ListSelectionEvent e)

{

String selection = (String) sizeList. getSelectedValue();

Size. setText(selection);

}

}

6 0
3 years ago
In this assignment, you will write a program that will contain two functions, setlsbs() and getlsbs(). These functions will use
kicyunya [14]

Answer:

#include "Lab11_jlilly3_204.h"

#include <stdio.h>

#include <stdlib.h>

#define BYTETOBINARYPATTERN "%d%d%d%d%d%d%d%d"

#define BYTETOBINARY(byte) \

(byte & 0x80 ? 1 : 0), \

(byte & 0x40 ? 1 : 0), \

(byte & 0x20 ? 1 : 0), \

(byte & 0x10 ? 1 : 0), \

(byte & 0x08 ? 1 : 0), \

(byte & 0x04 ? 1 : 0), \

(byte & 0x02 ? 1 : 0), \

(byte & 0x01 ? 1 : 0)

#define PRINTBIN(x) printf(BYTETOBINARYPATTERN, BYTETOBINARY(x));

//! Set the least significant bit for all values in an array to the coorrisponding bit pos. in b_o

void setlsbs(unsigned char* p, unsigned char b_0)

{

int i;

for (i = 0; i < 8; i++)

{

int x = b_0 & 1;

// If x is one set the low order bit to 1 using or

if (x)

{

p[i] |= x;

}

// If the value is a 0 and with one's complement to set lo to 0

else

{

p[i] &= ~1;

}

// shift our bit to the right to get the next value in the bit

b_0 = b_0 >> 1;

}

}

//! Get the least significant bit from each position in an array and add it to a byte

unsigned char getlsbs(unsigned char *p)

{

int i;

unsigned char c = 0;

for (i = 0; i < 8; i++)

{

// find out what the lsb is

int x = p[i] & 1;

if (x)

{

// if the lsb was a one insert a one and shift it into position

c |= 1 << i;

}

}

return c;

}

//! Print a given array in decimal

void print_decimal(unsigned char* p)

{

int k;

for (k = 0; k < 8; k++)

{

printf("Num at %d: %d\n", k, p[k]);

}

}

//! Print a given array in in bianary representation

void print_bin(unsigned char* p)

{

int c;

for (c = 0; c < 8; c++)

{

printf("Num at %d ", c);

PRINTBIN(p[c]);

printf("\n");

}

}

6 0
3 years ago
HOW DO YOU RUN YOUR SCRATCH PROGRAM?
kvv77 [185]

Answer:

By clicking on the green flag, it starts up the program and if you want to stop it use the stop sign.

5 0
3 years ago
Read 2 more answers
Other questions:
  • Why does people that gets abused not report?
    5·1 answer
  • In an airline reservation system, on entering the flight number, the flight schedule and the flight status are displayed. In thi
    13·2 answers
  • Each time the enter key is pressed, word creates a new paragraph. (points : 2) true false
    7·1 answer
  • Suppose arraylist list1 is [1, 2, 5] and arraylist list2 is [2, 3, 6]. after list1.addall(list2), list1 is __________.
    8·1 answer
  • Benching system are prohibited in
    5·1 answer
  • Consider the following class interfaces:
    8·1 answer
  • 1. Select the Volatile Memory *
    8·1 answer
  • বর্তমান করােনার ন্যায় পরিস্থিতি অর্থাৎ স্বাভাবিক শ্রেণি কার্যক্রম পরিচালনা সম্ভব
    10·2 answers
  • Many bookstores have closed since the rise of the Internet. What type of
    11·1 answer
  • The contrast ratio of green-60 text on a yellow-10 background is ___ to 1.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!