Question

In: Computer Science

Write Program in C: Write a program that: program starts; declares and initializes to 7.25% constant...

Write Program in C:

Write a program that: program starts; declares and initializes to 7.25% constant float variable NJSALES_TAX; declares and initializes to 1000 an integer variable total; declares and initializes to zero a float variable grand_total; prompt and input on new line total; calculate grand_total to equal total plus (total*NJSALES_TAX); if grand_total <= 1000 print on new line “Grand total is less than or equal to 1000 it is $” and the grand_total to two decimal places; else if grand_total between 1000 <= 2000 print on new line “Grand total is more than 1000 less than or equal to 2000 it is $” and the grand_total to two decimal places; else print on new line “Grand total is greater than 2000 it is $” and the grand_total to two decimal places; just before ending print on new line “Program finished!” then terminate program.

Solutions

Expert Solution

#include<stdio.h>
int main()
{
    float NJSALES_TAX = 7.25; //declare and initialize NJSALES_TAX to 7.25
    int total = 1000; //declare and initialize total to 1000
    float grand_total = 0; //declare and initialize grand_total to 0
    printf("\n Enter total : ");
    scanf("%d",&total); //read the total
    //compute the grand_ttal
    grand_total = total + (total * NJSALES_TAX);
    //condition for grand total less than and equal to 1000
    if(grand_total<=1000)
    printf("Grand total is less than or equal to 1000 it is $ %0.2f",grand_total);
    else //condition for grand_total greater than 1000 and less than or equal to 2000
    if(grand_total>1000 && grand_total<=2000)
    printf("Grand total is more than 1000 less than or equal to 2000 it is $ %0.2f",grand_total);
    else //grand_total greater than 2000
    printf("Grand total is greater than 2000 it is $%0.2f ",grand_total);
    //print finished message
    printf("\n Program finished!");
}

output


Related Solutions

In C programming: Write a program that initializes an array-of-double and then copies the contents of...
In C programming: Write a program that initializes an array-of-double and then copies the contents of the array into another arrays. To make the copy, use a function with array notation. This function takes two arguments the name of the target array and the number of elements to be copied. That is, the function calls would look like this, given the following declarations: double source[5] ={1.1, 2.2, 3.3., 4.4, 5.5}; double target1[5]; double target2[5]; copyarr(source, target1, 5);
Write Java program Lab43.java which declares and initializes numeric array of 5 elements (int num[5]) and...
Write Java program Lab43.java which declares and initializes numeric array of 5 elements (int num[5]) and produces as output the sum of integers in an array, the largest and the smallest element in an array. Your program should contain the following methods: public static int sum(int[]) public static int findLargest(int[]) public static int findSmallest(int[])
Write a small C program connect.c that: 1. Initializes an array id of N elements with...
Write a small C program connect.c that: 1. Initializes an array id of N elements with the value of the index of the array. 2. Reads from the keyboard or the command line a set of two integer numbers (p and q) until it encounters EOF or CTL - D 3. Given the two numbers, your program should connect them by going through the array and changing all the entries with the same name as p to have the same...
Write a small C program connect.c that: 1. Initializes an array id of N elements with...
Write a small C program connect.c that: 1. Initializes an array id of N elements with the value of the index of the array. 2. Reads from the keyboard or the command line a set of two integer numbers (p and q) until it encounters EOF or CTL - D 3. Given the two numbers, your program should connect them by going through the array and changing all the entries with the same name as p to have the same...
C Code Please! Declares a constant variable N and sets it to 42. * Declares an...
C Code Please! Declares a constant variable N and sets it to 42. * Declares an array of integers, with N elements, called fibonacci. * Declares an array of double floating-point numbers, with N-1 elements, called ratio. * Fills the fibonacci array with the numbers in the Fibonacci sequence (Wikipedia is your friend if you don't know what this sequence is about but you want to know).    Into the i-th element of the fibonacci array, you need to put...
Write a program in C that declares the following array: int. array[] = { 1, 2,...
Write a program in C that declares the following array: int. array[] = { 1, 2, 4, 8, 16, 32 } Then write some code that accepts a number between 0 and 5 from the user and stores it in a variable called "index". Write some code that retrieves the item specified by the index, like this: int item = array[index]; Then write code that outputs the corresponding array entry based on the number the user entered. Example output: The...
Write a program in C that does the following: 1. Declares an array called numbers_ary of...
Write a program in C that does the following: 1. Declares an array called numbers_ary of 6 integer numbers. 2. Declares an array called numbers_ary_sq of 6 integer numbers. 3. Reads and sets the values of numbers_ary from the keyboard using a loop. 4. Sets the values of numbers_ary_sq to the square of the values in numbers_ary using a loop. 5. Displays the values of numbers_ary and the values of numbers_ary_sq beside each other using a loop. Example Output Assume...
C Programming Only Write a program that declares a one-dimensional array of integers with 24 elements....
C Programming Only Write a program that declares a one-dimensional array of integers with 24 elements. Fill the array with random integers (use a loop). Neatly output each element in the one-dimensional array. Next convert your one-dimensional array of 24 elements into a two-dimensional array of 6 x 4 elements. Neatly output each element of the two-dimensional array. The values will be identical to the one-dimensional array – you’re just converting from one dimension to two.
Write a program in Java that initializes an array with ten random integers and then print...
Write a program in Java that initializes an array with ten random integers and then print three lines of output, containing: Every element at an odd index Every odd element All elements in reverse order   The program should use three different methods to implement the functionalities above. Call the primary source file ArrayManipulator.java
Write a program that initializes an array of 6 random integers and then prints 4 lines...
Write a program that initializes an array of 6 random integers and then prints 4 lines of output, containing the following: 1. Only the first and last element 2. Every element at an odd index 3. Every odd element 4. All elements in reverse order
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT