ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 4 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 22 May 2017 My Price 9.00

CSCI 1301: Introduction to Computing and Programming

How do I find the sum of all the numbers in an integer on java?

For example if I have the number 11, I want to find the sum of 1+2+3+4 .............., +11.

What would I do to find that out

 

CSCI 1301: Introduction to Computing and ProgrammingFall 2016Lab 06 – Input Validation, LoopsPart 1: Group Brainstorm (NO computers during this time)Good programmers think before they begin coding. Part I of this assignment involves brainstorming witha group of peers with absolutely no computers to talk about a strategy for solving this week’s lab.Breakup into groups based on your seating (3-4 people per group) and brainstorm about how to solve theproblem in Part 2 below. Make sure everyone understands the problem and sketch out potential ways tomove toward a solution. Write up a detailed description of your approach in English / pseudocode(English that is structured like a program). This should be 1-2 paragraphs in length (enough to convincethe grader that you have a plan for moving toward a solution). You may find it helpful to look over therequired readings for this week. Make sure to get the last names of those you have worked with – you willneed to provide it in your write-up for Part 2.Include in your write-up which course topics you think will be useful for the lab and a detailed plan forcompleting the exercise.You will want to discuss an algorithm for computing the reverse of an integerusing only mathematical operations.Part 2: Submit Individual Brainstorm (You can now use a computer)Login to eLC and submit a version of your group's brainstorm,written in your own wordsunder theAssignment Dropbox titled “Lab 6 Brainstorm”. *Note this is different than the Lab 6 Dropbox whereyou will submit your .java file for this assignment. Feel free to add any additional information that wasnot specified to your write-up. We prefer that you submit the brainstorm before the end of the first labperiod for the week. However, you can submit untilTuesday night at 9PM.Note: Brainstorms that are submitted without a student attending the lab will not begraded unless the student provides a documented excuse to the graduate TA.IntroductionIn this lab, the user will enter an integer input and your program will determine whether or not the giveninput is apalindrome, and if the given input is apalindrome, then your program will compute asummation involving thepalindrome. For this lab,loopstatements will be needed.Lab ObjectivesBy the end of the lab, you should:•validate user input and account for invalid user input•use loops to repeatedly perform calculations•use the modulus operator (%) to calculate remaindersPrerequisitesThe lab deals mainly with material from Chapter 4 (loops and debugging loops) but builds on materiallearned in Chapters 2-3.What to SubmitThe filePalindrome.javashould be submitted to eLC for grading.

import java.util.Scanner;public class Palindrome {public static void main(String[] args) {Scanner Keyboard = new Scanner(System.in);int n;int sum = 0 , reverse = 0;System.out.print("Please enter an integer >0:\t");n = Keyboard.nextInt();if (n<0) {System.out.print("Sorry you must enter an integer greater thanzero.");System.exit(0);}int copy = n;int min = 1;while (copy > 0){sum = copy % 10;reverse = (reverse*10)+sum;copy=copy/10;}if(n == reverse) {System.out.println(n + " is a palindrome number");int total = Math.addExact(min, n);System.out.print("The sum of the numbers from 1 to " + n +" is "+total);}else {System.out.print(n + " is not a palindrome number");}}private static int n(int i) {// TODO Auto-generated method stubreturn 0;}private static int copy(int i) {// TODO Auto-generated method stubreturn 0;}}

Attachments:

Answers

(11)
Status NEW Posted 22 May 2017 04:05 AM My Price 9.00

-----------

Attachments

file 1495429856-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)