main.c
#include <stdio.h>
#include "challenge.c"
static float a = 8.4;
int main() {
printf(“%f\n”, foo(a) + bar(a));
return 0;
}
challenge.c
#include "challenge2.c"
static float a;
float foo(float F) {
a = 3.6;
return bar(F) * a
}
challenge2.c
static float a;
float bar(float F) {
a = 3.8;
return F * a;
}
Given the source code above and that we use "gcc main.c -o challenge" to compile it, what is the output when we type ./challenge?
An integer number is said to be a perfect number if its factors, including 1 (but not the number itself), sum to the number. For example, 6 is a perfect number, because 6 = 1 + 2 + 3. Write a method perfect that determines whether parameter number is a perfect number. Use this method in an application that determines and displays all the perfect numbers between 1 and 1000. Display the factors of each perfect number to confirm that the number is indeed perfect. Challenge the computing power of your computer by testing numbers much larger than 1000. Display the results
A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $0.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is $10.00. Assume that no car parks for longer than 24 hours at a time. • Write an application that calculates and displays the parking charges for each customer who parked in the garage yesterday. You should enter the hours parked for each customer. The program should display the charge for the current customer and should calculate and display the running total of yesterday's receipts. The program should use the method calculateCharges to determine the charge for each customer
challenge.h
#include <stdio.h>
float foo(float F);
float bar(float F);
main.c
#include "challenge.h"
float a = 6.8;
int main() {
float fa = foo(a);
float ba = bar(a);
printf(“%.1f\n”, fa + ba);
return 0;
}
challenge.c
#include "challenge.h"
extern float a;
float foo(float F) {
a = 2.6;
return F * a
}
challenge2.c
#include "challenge.h"
static float a;
float bar(float F) {
a = 5.2;
return foo(F) * a;
}
Given the source code above and we use "gcc main.c challenge.c challenge2.c -o challenge" to compile it. What's the output when we type ./challenge
In correspondence to the flowchart shown in Figure 1.1, develop an application that will store the salesperson’s code, which is to be entered in the codeTextBox, in an Integer variable named code. The application will need to store the sales amount, which is to be entered in the salesTextBox, in a decimal variable named sales. Display the result of the calculation, or the error message, in the messageLabel. Name your Program SalesAccount.
Write a program that takes as input the size of the array and the elements in the array. The
program then asks the user to enter a particular index and prints the element at that index.
Use exception handling mechanisms to handle the accessing of array beyond the limit. In the
catch block, print "The required element is beyond the array limit".
Input format:
First line contains size of the array, second line contains array elements and third line contains
an array index.
Sample1
Input:
3
20
90
4
2
Output:
4
Sample2
Input:
3
20
90
4
5
Output:
The required element is beyond the array limit
Write a program to accept name and age of a person from the user and ensure that the age
entered is >=18 and < 60. If the given age is in specified range then print "Valid age"
The program must exit gracefully after displaying the error message "Age is not valid" in case
the arguments passed are not proper (age is not in specified range). You should create a user
defined exception class for handling this error.
Write a program that asks the user to enter an account number as a string. The account number consists of 8 characters and is divided as follows: The first 2 characters are digits and represent the branch (00 for Beirut, 01 for Saida, 02 for Tripoli). The remaining 6 characters represent the customer’s account number A valid account number consists of exactly 8 characters. If the account is valid, the program prints the details (branch and account number). If the account is not valid, the program displays a message to the user.
Implement a client class to test the Apartment class as follows: 1. Create an array of Apartment objects of size 5. 2. Fill it with five Apartment objects according to your choice as a programmer (NOT from the user) 3. Print the description of all apartments in the array which are located in “Beirut” 4. Display the size assessment of each apartment in the array. 5. Display the city of all apartment objects that are formed of two stories
How we Implement a generic Queue class in java and work with different data types (complete code)