C Programming – Define stubs for the functions called by the below main().

C Programming 6.3.2: Function stubs: Statistics. Define stubs for the functions called by the below main(). Each stub should print "FIXME: Finish FunctionName()" followed by a newline, and should return -1. Example output: FIXME: Finish GetUserNum() FIXME: Finish GetUserNum() FIXME: Finish ComputeAvg() Avg: -1 Answer #include <stdio.h>/* GetUserNum Stub*/int GetUserNum() { printf(“FIXME: Finish GetUserNum() \n”); … Read more

Print air_temperature with 1 decimal point followed by C. Sample output from given program: 36.4c

Print air_temperature with 1 decimal point followed by C. Sample output from given program: 36.4c Answer #Read the value from keyboard and parse to float#assign the value to air_temperatureair_temperature=float(input())#Print the air_temperature with one decimal place to right with Cprint(‘%.1fC’%air_temperature)#where f is a format specifier .1 is number of decimal places to display on right side#C … Read more

Open the file hostdata.txt for reading.

Python – files: find a solution for each following: Answer #1) host=open(“hostdata.txt”, “r”) #2) winter=open(“winter2003.txt”, “r”) spring=open(“spring2003.txt”, “r”) summer=open(“summer2003.txt”, “r”) fall=open(“fall2003.txt”, “r”) #3) summary=open(“yearsummary.txt”, “w”) #4) pi = open(“pi”,”w+”) pi.write(“3.14159”) pi.close() #5) data1 = open(“data1.txt”,”r”) data2 = open(“data2.txt”,”w+”) for line in data1: data2.write(line) data1.close() data2.close() #6). execution = open(“execution.log”,”a”) execution.write(“Program Execution Successful”) #7). corpdata.close() #8). … Read more

Write code to complete DoublePennies()’s base case. Sample output for below program:

Write code to complete DoublePennies()’s base case. Sample output for below program: Number of pennies after 10 days: 1024 #include <stdio.h>// Returns number of pennies if pennies are doubled numDays timeslong long DoublePennies(long long numPennies, int numDays){long long totalPennies = 0;/* Your solution goes here */else {totalPennies = DoublePennies((numPennies * 2), numDays – 1);}return totalPennies;}// … Read more

C Program – Assign negativeCntr with the number of negative values in the linked list

C Program – Assign negativeCntr with the number of negative values in the linked list, including the list head #include <stdio.h>#include <stdlib.h>typedef struct IntNode_struct {int dataVal;struct IntNode_struct* nextNodePtr;} IntNode;// Constructorvoid IntNode_Create(IntNode* thisNode, int dataInit, IntNode* nextLoc) {thisNode->dataVal = dataInit;thisNode->nextNodePtr = nextLoc;}/* Insert newNode after node.Before: thisNode — nextAfter: thisNode — newNode — next*/void IntNode_InsertAfter(IntNode* thisNode, … Read more

Write the printItem() method for the base class. Sample output for below program:

Write the printItem() method for the base class. Sample output for below program: Last name: Smith First and last name: Bill Jones // ===== Code from file BaseItem.java =====public class BaseItem {protected String lastName;public void setLastName(String providedName) {lastName = providedName;return;}// FIXME: Define printItem() method/* Your solution goes here */}// ===== end =====// ===== Code from … Read more

[PYTHON] A software company sells a package that retails for $99

PYTHON: A software company sells a package that retails for $99. Quantity discounts are given according to the following table: Write a program that asks the user to enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total amount of the purchase after the … Read more

(Java) Complete the method definition to output the hours given minutes.

(Java) Complete the method definition to output the hours given minutes. Output for sample program: 3.5 secretID.concat(spaceChar); secretID.concat(lastName);import java.util.Scanner;public class CombiningStrings { public static void main (String [] args) { String secretID = “Barry”; String lastName = “Allen”; char spaceChar = ‘ ‘; /* Your solution goes here */ System.out.println(secretID); return; }} Answer /**************************************************** This … Read more

5.6 Warm up: Parsing strings (Java)

5.6 Warm up: Parsing strings (Java) Answer import java.util.Scanner; public class ParseStrings { public static void main(String[] args) { Scanner sc = new Scanner(System.in);//to read input from user String str;//to hold strig entered by user System.out.println("Enter input string");//asking user to enter a string str=sc.nextLine();//reading into str while(!str.equalsIgnoreCase("q")) { while(!str.contains(","))//checking valid word or not { System.out.println("Error: … Read more

BMI Formula: Write a Python Program that asks the user for weight and height and then displays weight class based on BMI

BMI Formula: Write a Python Program that asks the user for weight and height and then displays weight class based on BMI Answer # define functions def bmi(weight, height): return (weight*703)/(height*height) # take input from the user print("BMI calculate") weight = int(input("Enter weight: ")) height = int(input("Enter height: ")) bmi = bmi(weight,height)) if bmi < … Read more

Define the missing method. Use “this” to distinguish the local member from the parameter name.

Define the missing method. Use "this" to distinguish the local member from the parameter name. Answer // ===== Code from file CablePlan.java ===== public class CablePlan { private int numDays; // FIXME: Define setNumDays() method, using "this" implicit parameter. public void setNumDays(int numDays) { this.numDays = numDays; } public int getNumDays() { return numDays; } … Read more

Set hasDigit to true if the 3-character passCode contains a digit.

In Java; Set hasDigit to true if the 3-character passCode contains a digit. Answer import java.util.Scanner; public class CheckingPasscodes { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); boolean hasDigit; String passCode; hasDigit = false; passCode = scnr.next(); // the string is passCode and not userInput // also you didn't … Read more

Write nested loops to print a rectangle. Sample output for given program:

Write nested loops to print a rectangle. Sample output for given program: * * * * * * Answer #Variable declaration num_rows=2 num_cols=3 #For loop for number of rows for p in range(num_rows): #For loop for number of columns for q in range(num_cols): # Display the statement print ('*',end= ' ') #next statement print('')

Write a method printshampooinstructions() with int parameter numcycles and void return type

Write a method printshampooinstructions() with int parameter numcycles and void return type Answer import java.util.Scanner; public class ShampooMethod { static void printShampooInstructions(int numCycles) { if (numCycles < 1) { System.out.println("Too few.."); } else if (numCycles > 4) { System.out.println("Too many.."); } else { for (int i = 1; i <= numCycles; ++i) { System.out.println(i + … Read more

Define a method printFeetInchShort, with int parameters numFeet and numInches

Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints using ‘ and " shorthand. End with a newline. Ex: printFeetInchShort(5, 8) prints: 5’ 8" Answer import java.util.Scanner; public class HeightPrinter { public static void printFeetInchShort(int numFeet, int numInches) { System.out.println(numFeet + "' " + numInches + "\""); } public static void main(String[] … Read more

Complete the method definition to output the hours given minutes. Output for sample program: 3.5

Complete the method definition to output the hours given minutes. Output for sample program: 3.5 Answer import java.util.Scanner; public class HourToMinConv { public static void outputMinutesAsHours(double origMinutes) { System.out.print(origMinutes / 60); } public static void main(String[] args) { Scanner scnr = new Scanner(System.in); double minutes; minutes = scnr.nextDouble(); outputMinutesAsHours(minutes); // Will be run with 210.0, … Read more