Questions
Write a function printTwoLargest() that inputs an arbitrary number of positive numbers from the user. The...

  1. Write a function printTwoLargest() that inputs an arbitrary number of positive numbers from the user. The input of numbers stops when the first negative or zero value is entered by the user. The function then prints the two largest values entered by the user. If no positive numbers are entered a message to that effect is printed instead of printing any numbers. If only one number is inputted, only the largest is printed out (see 2nd example below). Sample output:

>>> printTwoLargest()

Please enter a number: 12

Please enter a number: 99.9

Please enter a number: 4.5

Please enter a number: 77

Please enter a number: 0

The largest is 99.9

The second largest is 77

>>> printTwoLargest()

Please enter a number: 23.2

Please enter a number: -99

The largest is 23.2

>>> printTwoLargest()

Please enter a number: -9

No positive numbers were entered

>>>

  1. Test your code by downloading the file lab1TEST.py in the same working folder and add the following code to the bottom of your lab1.py module. Run and fix errors before you submit.

if __name__=='__main__':
    import doctest
    print( doctest.testfile( 'lab1TEST.py' ))

use puthon 3.7

In: Computer Science

write exactly what the following code prints. Ensure that you write in the correct order. clearly...

write exactly what the following code prints. Ensure that you write in the correct order. clearly distinguish scratch work from your final answer.

Public class Base{

public void m1(Base a){

System.out.println("Base m1");

a.m2();

}

public void m2(){

System.out.println("Base m2");

}

}

Public class Derived1 extends Base{

public void m1(Base b){

System.out.println("Derived1 m1");

}

public void m2(){

System.out.println("Derived1 m2");

}

}

Public class Derived2 extends Base{

public void m2(){

System.out.m2(){

System.out.println("Dertived2 m2");

}

}

public class UserBaseAndDerived1And2{

public static void main(String[] args){

Base b = new Base();

Derived1 d1 = new Derived1();

Derived2 d2 = new Derived2();

b.m1(b);

b.m1(d1);

b.m1(d2);

b =d1;

b.m1(d2);

b = d2;

b.m1(d1);

}

}

In: Computer Science

How can I check that if a string only make from specific character? For example, I...

How can I check that if a string only make from specific character?
For example, I want to check if a string only make from ICDM characters. It pass the test if it makes from ICMD. It fail the test if it makes from any special character like @#$& or lower case.
Example inputs:
if string = CIM, it passed
if string = AIM, it failed
if string = MCDI, it passed
if string = ICDF, it failed

This can be in either java or php language. Any help with detail is appreciated. Thank you!

In: Computer Science

Make a program to read a file, filled with words separated by new lines, from command...

Make a program to read a file, filled with words separated by new lines, from command line arguments (args[0]), print the file, and then add each word into an arraylist.

After making the arraylist, iterate through it and print its contents.

In: Computer Science

One of the most highly touted advantages of Linux is the fact that it is open...

One of the most highly touted advantages of Linux is the fact that it is open source and anyone can view, modify, and contribute to the Linux source code. In this project, you will make a small change to the Linux source code.

Follow the instructions called Linux Kernel Modules beginning on page 96 of the textbook. Take screenshots of the code that you add to the Linux source as you go and paste them into a Word document.

In the final part of the assignment, you will also need to take screenshots of the kernel log buffer to show successful addition, traversal, and deletion of the linked list elements. Finally, you will need to write a one to two-page reflection paper documenting the steps you have been through to complete the project, lesson learned, things that you like and dislike most about this project, difficulties you encountered and how you solved them, and what you should have done to avoid such difficulties.

Helpful Information on C and Linux:

  • You may need to install a virtual machine to complete the project. Please see the textbook for more information about installing VMware player.
  • C language reference: The GNU C Reference Manual (Links to an external site.)
  • Another C language reference: C and C++ Language (Links to an external site.) Syntax Reference
  • Yet another C language reference: C reference (Links to an external site.)
  • Compiling with gcc and make: Compiling, Linking and Building C/C++ Applications

In: Computer Science

Write a program that will accept user input for an initial deposit and a total amount...

Write a program that will accept user input for an initial deposit and a total amount the user wants to have, and will output the number of years it will take to reach his/her goal. For the basic program, the user will deposit the initial amount in a new account, and then the account will receive interest, compounded MONTHLY, at a rate of 0.5%.

In: Computer Science

Programming Challenge #10. C++ Early Objects 10ed. A talent competition has five judges, each of whom...

Programming Challenge #10. C++ Early Objects 10ed.

A talent competition has five judges, each of whom awards a score between 0 and 10 to each performer. Fractional scores, such as 8.3, are allowed. A performer's final score is determined by dropping the highest and lowest score received, then averaging

#include <iostream>
#include <iomanip>
using namespace std;

// Function prototypes
double getJudgeData();  
double calcScore(double, double, double, double, double);                       
double findLowest(double, double, double, double, double);                      
double findHighest(double, double, double, double, double);
                
int main()
{
        double score1, score2, score3, score4, score5,   // 5 judge's scores
          finalScore;
   
        // Inform the user what the program does
        cout << "After you enter 5 judge scores for this contestant, \n"
        << "this program will drop the highest and lowest score \n"
        << "and then average the remaining three scores.\n\n";
        

        return 0;
}// end of main function


the three remaining scores. Write a program that uses these rules to calculate and display a contestant's score.

In: Computer Science

How can I make my php code without using the money format just loop and if...

How can I make my php code without using the money format just loop and if statements print like this:

Change for 5 dollars and 20 cents:

0 ten dollar bills
1 five dollar bills
0 one dollar bills

0 quarters

2 dime
0 nickel
0 pennies

I am trying to ask the user to enter amount and output their change they entered.

$input;

$TenBills = 1000;

$FiveBills = 500;

$OneBills = 100;

$Quarters = 25;

$Dimes = 10;

$Nickels = 5;

$Pennies = 1;

//$dollars = $TenBills , $FiveBills , $OneBills;

$input = readline("Enter Dollars:\n");

print "Change for $input cents:\n";



if($input >= $TenBills) {

$TenBills = $input/$TenBills;

$input /= $TenBills * $TenBills;

print " $input ten dollar bills\n";

}

if($input = $FiveBills) {

$FiveBills = $input/$FiveBills;

$input /= $FiveBills * $FiveBills;

print " $input five dollar bills\n";

}

if($input = $OneBills) {

$OneBills = $input/$OneBills;

$input /= $OneBills * $OneBills;

print " $input one dollar bills\n";

}

if($input = $Quarters) {

$Quarters = $input/$Quarters;

$input /= $Quarters * $Quarters;

print " $input quarters dollar bills\n";

}

if($input = $Dimes) {

$Dimes = $input/$Dimes;

$input /= $Dimes * $Dimes;

print " $input dimes dollar bills\n";

}

if($input = $Nickels) {

$Nickels = $input/$Nickels;

$input /= $Nickels * $Nickels;

print " $input nickels dollar bills\n";

}

if($input = $Pennies) {

$Pennies = $input/$Pennies;

$input /= $Pennies * $Pennies;

print " $input pennies dollar bills\n";

}




?>


In: Computer Science

​Write a program which requests two weights in kilograms and grams and prints the sum of...

​Write a program which requests two weights in kilograms and grams and prints the sum of the weights. For example, if the weights are 3kg 500g and 4kg 700g, your program should print 8kg 200g. in c programming selection logic

In: Computer Science

Create a function powerTo which receives two parameters, a floating point number (the first parameter) and...

Create a function powerTo which receives two parameters, a floating point number (the first parameter) and an integer (the second parameter). If the second parameter is nonnegative, the function returns the value of the first parameter raised to the power of the second parameter. Otherwise, if the second parameter is negative the function returns 0. For example powerTo(2,3)=8, and powerTo(2,-3)=0

In: Computer Science

1. Discuss the following system development methods (600 words approx.) – Structured development – Object oriented...

1. Discuss the following system development methods (600 words approx.) – Structured development – Object oriented development – Agile development – Rapid Application Development

2. What is project creep? Which system development methods are more prone to project creep? What could be a strategy to avoid it? (400 words approx.)

In: Computer Science

1. Henry is having a problem with the electrical system on his current laptop. The battery...

1. Henry is having a problem with the electrical system on his current laptop. The battery for the laptop will not charge. Henry took the AC adapter and battery from another laptop that is known to work, and put them in his current laptop, but still the battery will not charge.

What possible actions can Henry take to make his laptop usable? (Select all that apply.)

a) Henry can replace the battery again, as the second battery could also be bad.

  b) Henry can replace the laptop system board.

c) Henry can purchase a new laptop.

d) Henry can use the laptop only when it’s connected to the power using the AC adapter.

2. When you turn on your computer for the day, you notice lights and fans but no beeps and no video. The Num Lock light does not come on.

What might be the problem with your computer? (Select all that apply.)

a) Motherboard has failed.

b) Video is not working properly.

c) Processor has failed or is not seated properly.

d) Power supply is not working properly.

e) RAM is not working properly.

In: Computer Science

Determine Theta for the following code fragments in the average case. Explain your answer. a =...

Determine Theta for the following code fragments in the average case. Explain your answer.

  1. a = b + c;

d = a + e;

  1. sum = 0;

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

for (j=0; j

sum++;

3. sum = 0;

for (i=1; i<=n; i*=2)

for (j=1; j<=n; j++)

sum++;

4. Assume that array A contains n values, Random takes constant time,

and sort takes n log n steps.

for (i=0; i

for (j=0; j

A[j] = Random(n);

sort(A, n);

5. Assume array A contains a random permutation of the values from 0 to n - 1.

sum = 0;

for (i=0; i

for (j=0; A[j]!=i; j++)

sum++;

In: Computer Science

CHALLENGE ACTIVITY 3.12.1: String comparison: Detect word. Write an if-else statement that prints "Goodbye" if userString...

CHALLENGE

ACTIVITY

3.12.1: String comparison: Detect word.

Write an if-else statement that prints "Goodbye" if userString is "Quit", else prints "Hello". End with newline.

import java.util.Scanner;

public class DetectWord {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
String userString;

userString = scnr.next();

/* Your solution goes here */

}
}

In: Computer Science

Write a function in JAVASCRIPT that accepts two arguments (a string array and a character). The...

Write a function in JAVASCRIPT that accepts two arguments (a string array and a character). The function will check each character of the strings in the array and removes the character, regardless of case. If the first letter of the string is removed the next letter must be capitalized. Your function would return the result as one string, where each element of array is separated by comma. E.G. function([“John”,”Hannah”,”Saham”], “h”); // returns ‘Jon,Anna,Saam

Use of any built in string function or any built in array function is not alllowed,

any help would be much appreciated.

In: Computer Science